change detail to details, more ideas for howto mobile and safe

This commit is contained in:
Bel LaPointe
2021-12-31 21:17:37 -05:00
parent 141a374441
commit cb0f268454
4 changed files with 26 additions and 14 deletions

View File

@@ -10,9 +10,9 @@ import (
func TestJSONRoot(t *testing.T) {
root := Root{
Todo: []Todo{Todo{Todo: "todo", Detail: "detail", Schedule: "teehee", TS: 1}},
Scheduled: []Todo{Todo{Todo: "scheduled", Detail: "detail", Schedule: "teehee", TS: 1}},
Done: []Todo{Todo{Todo: "done", Detail: "detail", Schedule: "teehee", TS: 1}},
Todo: []Todo{Todo{Todo: "todo", Details: "detail", Schedule: "teehee", TS: 1}},
Scheduled: []Todo{Todo{Todo: "scheduled", Details: "detail", Schedule: "teehee", TS: 1}},
Done: []Todo{Todo{Todo: "done", Details: "detail", Schedule: "teehee", TS: 1}},
}
var root2 Root
if b, err := json.Marshal(root); err != nil {

View File

@@ -7,7 +7,7 @@ import (
type Todo struct {
Todo string
Detail string `yaml:",omitempty"`
Details string `yaml:",omitempty"`
TS TS `yaml:",omitempty"`
Schedule Schedule `yaml:",omitempty"`
Tags string `yaml:",omitempty"`

View File

@@ -13,7 +13,7 @@ func TestJSONTodo(t *testing.T) {
todo := func() Todo {
return Todo{
Todo: "todo",
Detail: "detail",
Details: "detail",
TS: TS(1),
Schedule: Schedule("schedule"),
}
@@ -68,7 +68,7 @@ todo: my full task here
if err := yaml.Unmarshal([]byte(`
todo:
todo: the todo part of my task
detail: whatever
details: whatever
schedule: "* * * * *"
`), &littleRoot); err != nil {
t.Fatal(err)
@@ -76,7 +76,7 @@ todo:
if littleRoot.Todo.Todo != "the todo part of my task" {
t.Fatal(littleRoot)
}
if littleRoot.Todo.Detail != "whatever" {
if littleRoot.Todo.Details != "whatever" {
t.Fatal(littleRoot)
}
if littleRoot.Todo.Schedule != "* * * * *" {
@@ -114,14 +114,14 @@ func TestMarshalTodo(t *testing.T) {
t.Run(`struct should return struct`, func(t *testing.T) {
var todo Todo
if b, err := yaml.Marshal(Todo{Todo: "a", Detail: "b"}); err != nil {
if b, err := yaml.Marshal(Todo{Todo: "a", Details: "b"}); err != nil {
t.Fatal(err)
} else if err := yaml.Unmarshal(b, &todo); err != nil {
t.Fatal(err)
} else if todo.Todo != "a" {
t.Fatal(todo.Todo)
} else if todo.Detail != "b" {
t.Fatal(todo.Detail)
} else if todo.Details != "b" {
t.Fatal(todo.Details)
}
})
}