2021-01-29 17:22:07 +01:00
|
|
|
package task_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"testing"
|
|
|
|
|
2021-05-13 09:47:06 +02:00
|
|
|
"git.ewintr.nl/go-kit/test"
|
|
|
|
"git.ewintr.nl/gte/internal/task"
|
|
|
|
"git.ewintr.nl/gte/pkg/mstore"
|
2021-01-29 17:22:07 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestNewFromMessage(t *testing.T) {
|
|
|
|
id := "an id"
|
2021-01-30 11:20:12 +01:00
|
|
|
version := 2
|
2021-01-29 17:22:07 +01:00
|
|
|
action := "some action"
|
2021-01-29 19:40:46 +01:00
|
|
|
project := "project"
|
2021-01-30 15:25:25 +01:00
|
|
|
date := task.NewDate(2021, 1, 20)
|
2021-06-04 08:01:40 +02:00
|
|
|
recurs := "2021-06-04, daily"
|
2021-01-29 19:40:46 +01:00
|
|
|
|
2021-01-29 17:22:07 +01:00
|
|
|
for _, tc := range []struct {
|
2021-06-04 10:45:56 +02:00
|
|
|
name string
|
|
|
|
message *mstore.Message
|
|
|
|
hasId bool
|
|
|
|
exp *task.Task
|
2021-01-29 17:22:07 +01:00
|
|
|
}{
|
|
|
|
{
|
|
|
|
name: "empty",
|
|
|
|
message: &mstore.Message{},
|
2021-06-04 10:45:56 +02:00
|
|
|
exp: &task.Task{},
|
2021-01-29 17:22:07 +01:00
|
|
|
},
|
|
|
|
{
|
2021-07-10 11:29:48 +02:00
|
|
|
name: "id, action, project, folder and done",
|
2021-01-29 17:22:07 +01:00
|
|
|
message: &mstore.Message{
|
2021-01-30 15:25:25 +01:00
|
|
|
Folder: task.FOLDER_UNPLANNED,
|
2021-01-29 17:22:07 +01:00
|
|
|
Body: fmt.Sprintf(`
|
|
|
|
id: %s
|
2021-01-30 15:25:25 +01:00
|
|
|
due: no date
|
2021-01-30 11:20:12 +01:00
|
|
|
version: %d
|
2021-01-29 17:22:07 +01:00
|
|
|
action: %s
|
2021-01-29 19:40:46 +01:00
|
|
|
project: %s
|
2021-07-10 11:29:48 +02:00
|
|
|
done: true
|
2021-01-30 11:20:12 +01:00
|
|
|
`, id, version, action, project),
|
2021-01-29 17:22:07 +01:00
|
|
|
},
|
2021-06-04 10:45:56 +02:00
|
|
|
hasId: true,
|
2021-01-29 17:22:07 +01:00
|
|
|
exp: &task.Task{
|
2021-01-29 19:40:46 +01:00
|
|
|
Id: id,
|
2021-01-30 11:20:12 +01:00
|
|
|
Version: version,
|
2021-01-30 15:25:25 +01:00
|
|
|
Folder: task.FOLDER_UNPLANNED,
|
2021-01-29 19:40:46 +01:00
|
|
|
Action: action,
|
|
|
|
Project: project,
|
2021-07-10 11:29:48 +02:00
|
|
|
Done: true,
|
2021-01-29 17:22:07 +01:00
|
|
|
},
|
|
|
|
},
|
2021-01-30 15:25:25 +01:00
|
|
|
{
|
|
|
|
name: "with date",
|
|
|
|
message: &mstore.Message{
|
|
|
|
Folder: task.FOLDER_PLANNED,
|
|
|
|
Body: fmt.Sprintf(`
|
|
|
|
id: %s
|
|
|
|
due: %s
|
|
|
|
version: %d
|
|
|
|
action: %s
|
|
|
|
`, id, date.String(), version, action),
|
|
|
|
},
|
2021-06-04 10:45:56 +02:00
|
|
|
hasId: true,
|
2021-01-30 15:25:25 +01:00
|
|
|
exp: &task.Task{
|
|
|
|
Id: id,
|
|
|
|
Folder: task.FOLDER_PLANNED,
|
|
|
|
Action: action,
|
|
|
|
Version: version,
|
|
|
|
Due: date,
|
|
|
|
},
|
|
|
|
},
|
2021-01-29 17:22:07 +01:00
|
|
|
{
|
2021-01-31 08:22:31 +01:00
|
|
|
name: "action in body takes precedence",
|
2021-01-29 17:22:07 +01:00
|
|
|
message: &mstore.Message{
|
2021-01-30 15:25:25 +01:00
|
|
|
Folder: task.FOLDER_PLANNED,
|
2021-01-29 17:22:07 +01:00
|
|
|
Subject: "some other action",
|
|
|
|
Body: fmt.Sprintf(`
|
|
|
|
id: %s
|
2021-01-30 15:25:25 +01:00
|
|
|
due: no date
|
2021-01-30 11:20:12 +01:00
|
|
|
version: %d
|
2021-01-29 17:22:07 +01:00
|
|
|
action: %s
|
2021-01-30 11:20:12 +01:00
|
|
|
`, id, version, action),
|
2021-01-29 17:22:07 +01:00
|
|
|
},
|
2021-06-04 10:45:56 +02:00
|
|
|
hasId: true,
|
2021-01-29 17:22:07 +01:00
|
|
|
exp: &task.Task{
|
2021-01-30 11:20:12 +01:00
|
|
|
Id: id,
|
|
|
|
Version: version,
|
2021-01-30 15:25:25 +01:00
|
|
|
Folder: task.FOLDER_PLANNED,
|
2021-01-30 11:20:12 +01:00
|
|
|
Action: action,
|
2021-01-29 17:22:07 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "action from subject if not present in body",
|
|
|
|
message: &mstore.Message{
|
2021-01-30 15:25:25 +01:00
|
|
|
Folder: task.FOLDER_PLANNED,
|
2021-01-29 17:22:07 +01:00
|
|
|
Subject: action,
|
|
|
|
Body: fmt.Sprintf(`id: %s`, id),
|
|
|
|
},
|
2021-01-29 17:48:22 +01:00
|
|
|
hasId: true,
|
|
|
|
exp: &task.Task{
|
|
|
|
Id: id,
|
2021-01-30 15:25:25 +01:00
|
|
|
Folder: task.FOLDER_PLANNED,
|
2021-01-29 17:48:22 +01:00
|
|
|
Action: action,
|
|
|
|
},
|
|
|
|
},
|
2021-01-31 08:22:31 +01:00
|
|
|
{
|
|
|
|
name: "project in body takes precedence",
|
|
|
|
message: &mstore.Message{
|
|
|
|
Folder: task.FOLDER_PLANNED,
|
|
|
|
Subject: fmt.Sprintf("old project - %s", action),
|
|
|
|
Body: fmt.Sprintf(`
|
|
|
|
id: %s
|
|
|
|
due: no date
|
|
|
|
version: %d
|
|
|
|
action: %s
|
|
|
|
project: %s
|
|
|
|
`, id, version, action, project),
|
|
|
|
},
|
2021-06-04 10:45:56 +02:00
|
|
|
hasId: true,
|
2021-01-31 08:22:31 +01:00
|
|
|
exp: &task.Task{
|
|
|
|
Id: id,
|
|
|
|
Version: version,
|
|
|
|
Folder: task.FOLDER_PLANNED,
|
|
|
|
Action: action,
|
|
|
|
Project: project,
|
|
|
|
},
|
|
|
|
},
|
2021-01-29 17:48:22 +01:00
|
|
|
{
|
|
|
|
name: "quoted fields",
|
|
|
|
message: &mstore.Message{
|
2021-01-30 15:25:25 +01:00
|
|
|
Folder: task.FOLDER_PLANNED,
|
2021-01-29 17:48:22 +01:00
|
|
|
Body: fmt.Sprintf(`
|
|
|
|
action: %s
|
|
|
|
|
|
|
|
Forwarded message:
|
|
|
|
> id: %s
|
|
|
|
> action: old action
|
|
|
|
`, action, id),
|
|
|
|
},
|
|
|
|
hasId: true,
|
2021-01-29 17:22:07 +01:00
|
|
|
exp: &task.Task{
|
|
|
|
Id: id,
|
2021-01-30 15:25:25 +01:00
|
|
|
Folder: task.FOLDER_PLANNED,
|
2021-01-29 17:22:07 +01:00
|
|
|
Action: action,
|
|
|
|
},
|
|
|
|
},
|
2021-06-04 08:01:40 +02:00
|
|
|
{
|
2021-06-04 10:45:56 +02:00
|
|
|
name: "recur",
|
2021-06-04 08:01:40 +02:00
|
|
|
message: &mstore.Message{
|
|
|
|
Folder: task.FOLDER_INBOX,
|
|
|
|
Body: fmt.Sprintf(`
|
|
|
|
action: %s
|
|
|
|
due: no date
|
|
|
|
recur: %s
|
|
|
|
project: %s
|
|
|
|
id :%s
|
|
|
|
version: %d
|
|
|
|
`, action, recurs, project, id, version),
|
|
|
|
},
|
2021-06-04 10:45:56 +02:00
|
|
|
hasId: true,
|
2021-06-04 08:01:40 +02:00
|
|
|
exp: &task.Task{
|
|
|
|
Id: id,
|
2021-06-04 10:45:56 +02:00
|
|
|
Version: version,
|
|
|
|
Folder: task.FOLDER_INBOX,
|
2021-06-04 08:01:40 +02:00
|
|
|
Action: action,
|
|
|
|
Project: project,
|
|
|
|
Recur: task.Daily{Start: task.NewDate(2021, 6, 4)},
|
|
|
|
},
|
|
|
|
},
|
2021-01-29 17:22:07 +01:00
|
|
|
} {
|
|
|
|
t.Run(tc.name, func(t *testing.T) {
|
2021-06-04 10:45:56 +02:00
|
|
|
act := task.NewFromMessage(tc.message)
|
2021-01-29 17:22:07 +01:00
|
|
|
if !tc.hasId {
|
|
|
|
test.Equals(t, false, "" == act.Id)
|
|
|
|
tc.exp.Id = act.Id
|
|
|
|
}
|
|
|
|
tc.exp.Message = tc.message
|
|
|
|
test.Equals(t, tc.exp, act)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-04 10:45:56 +02:00
|
|
|
func TestTaskTargetFolder(t *testing.T) {
|
|
|
|
for _, tc := range []struct {
|
|
|
|
name string
|
|
|
|
tsk *task.Task
|
|
|
|
expFolder string
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
name: "new",
|
|
|
|
tsk: &task.Task{},
|
|
|
|
expFolder: task.FOLDER_NEW,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "recurring",
|
|
|
|
tsk: &task.Task{
|
|
|
|
Id: "id",
|
|
|
|
Version: 2,
|
|
|
|
Recur: task.Daily{Start: task.NewDate(2021, 06, 21)},
|
|
|
|
},
|
|
|
|
expFolder: task.FOLDER_RECURRING,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "planned",
|
|
|
|
tsk: &task.Task{
|
|
|
|
Id: "id",
|
|
|
|
Version: 2,
|
|
|
|
Due: task.NewDate(2021, 06, 21),
|
|
|
|
},
|
|
|
|
expFolder: task.FOLDER_PLANNED,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "unplanned",
|
|
|
|
tsk: &task.Task{
|
|
|
|
Id: "id",
|
|
|
|
Version: 2,
|
|
|
|
},
|
|
|
|
expFolder: task.FOLDER_UNPLANNED,
|
|
|
|
},
|
|
|
|
} {
|
|
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
|
|
test.Equals(t, tc.tsk.TargetFolder(), tc.expFolder)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestTaskNextMessage(t *testing.T) {
|
|
|
|
for _, tc := range []struct {
|
|
|
|
name string
|
|
|
|
tsk *task.Task
|
|
|
|
expMessage *mstore.Message
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
name: "empty",
|
|
|
|
tsk: &task.Task{},
|
|
|
|
expMessage: &mstore.Message{
|
|
|
|
Folder: task.FOLDER_NEW,
|
|
|
|
Subject: "",
|
|
|
|
Body: `
|
|
|
|
action:
|
|
|
|
due: no date
|
|
|
|
project:
|
|
|
|
version: 1
|
|
|
|
id:
|
|
|
|
`,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "normal",
|
|
|
|
tsk: &task.Task{
|
|
|
|
Id: "id",
|
|
|
|
Version: 3,
|
|
|
|
Folder: task.FOLDER_INBOX,
|
|
|
|
Action: "action",
|
|
|
|
Project: "project",
|
|
|
|
Due: task.NewDate(2021, 06, 22),
|
|
|
|
},
|
|
|
|
expMessage: &mstore.Message{
|
|
|
|
Folder: task.FOLDER_PLANNED,
|
|
|
|
Subject: "2021-06-22 (tuesday) - project - action",
|
|
|
|
Body: `
|
|
|
|
action: action
|
|
|
|
due: 2021-06-22 (tuesday)
|
|
|
|
project: project
|
|
|
|
version: 4
|
|
|
|
id: id
|
|
|
|
`,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
} {
|
|
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
|
|
test.Equals(t, tc.expMessage, tc.tsk.NextMessage())
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-29 17:22:07 +01:00
|
|
|
func TestFormatSubject(t *testing.T) {
|
|
|
|
action := "an action"
|
2021-01-29 19:40:46 +01:00
|
|
|
project := " a project"
|
2021-01-30 15:25:25 +01:00
|
|
|
due := task.NewDate(2021, 1, 30)
|
2021-01-29 19:40:46 +01:00
|
|
|
|
2021-01-29 17:22:07 +01:00
|
|
|
for _, tc := range []struct {
|
|
|
|
name string
|
|
|
|
task *task.Task
|
|
|
|
exp string
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
name: "empty",
|
|
|
|
task: &task.Task{},
|
|
|
|
},
|
|
|
|
{
|
2021-01-29 19:40:46 +01:00
|
|
|
name: "action",
|
2021-01-30 15:25:25 +01:00
|
|
|
task: &task.Task{
|
|
|
|
Action: action,
|
|
|
|
},
|
|
|
|
exp: action,
|
2021-01-29 17:22:07 +01:00
|
|
|
},
|
2021-01-29 19:40:46 +01:00
|
|
|
{
|
|
|
|
name: "project",
|
2021-01-30 15:25:25 +01:00
|
|
|
task: &task.Task{
|
|
|
|
Project: project,
|
|
|
|
},
|
|
|
|
exp: project,
|
2021-01-29 19:40:46 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "action and project",
|
2021-01-30 15:25:25 +01:00
|
|
|
task: &task.Task{
|
|
|
|
Action: action,
|
|
|
|
Project: project,
|
|
|
|
},
|
|
|
|
exp: fmt.Sprintf("%s - %s", project, action),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "action, date and project",
|
|
|
|
task: &task.Task{
|
|
|
|
Action: action,
|
|
|
|
Project: project,
|
|
|
|
Due: due,
|
|
|
|
},
|
|
|
|
exp: fmt.Sprintf("%s - %s - %s", due.String(), project, action),
|
2021-01-29 19:40:46 +01:00
|
|
|
},
|
2021-01-29 17:22:07 +01:00
|
|
|
} {
|
|
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
|
|
test.Equals(t, tc.exp, tc.task.FormatSubject())
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestFormatBody(t *testing.T) {
|
|
|
|
id := "an id"
|
2021-01-30 11:20:12 +01:00
|
|
|
version := 6
|
2021-01-29 17:22:07 +01:00
|
|
|
action := "an action"
|
2021-01-29 19:40:46 +01:00
|
|
|
project := "project"
|
|
|
|
|
2021-01-29 17:22:07 +01:00
|
|
|
for _, tc := range []struct {
|
|
|
|
name string
|
|
|
|
task *task.Task
|
|
|
|
exp string
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
name: "empty",
|
|
|
|
task: &task.Task{},
|
|
|
|
exp: `
|
|
|
|
action:
|
2021-01-30 15:25:25 +01:00
|
|
|
due: no date
|
|
|
|
project:
|
|
|
|
version: 0
|
|
|
|
id:
|
2021-01-29 17:22:07 +01:00
|
|
|
`,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "filled",
|
|
|
|
task: &task.Task{
|
2021-01-29 19:40:46 +01:00
|
|
|
Id: id,
|
2021-01-30 11:20:12 +01:00
|
|
|
Version: version,
|
2021-01-29 19:40:46 +01:00
|
|
|
Action: action,
|
|
|
|
Project: project,
|
2021-07-11 12:02:16 +02:00
|
|
|
Done: true,
|
2021-01-30 15:25:25 +01:00
|
|
|
Due: task.NewDate(2021, 1, 30),
|
2021-01-29 18:10:06 +01:00
|
|
|
Message: &mstore.Message{
|
|
|
|
Body: "previous body",
|
|
|
|
},
|
2021-01-29 17:22:07 +01:00
|
|
|
},
|
|
|
|
exp: `
|
2021-01-29 19:40:46 +01:00
|
|
|
action: an action
|
2021-01-30 15:25:25 +01:00
|
|
|
due: 2021-01-30 (saturday)
|
|
|
|
project: project
|
|
|
|
version: 6
|
|
|
|
id: an id
|
2021-07-11 12:02:16 +02:00
|
|
|
done: true
|
2021-01-29 18:10:06 +01:00
|
|
|
|
|
|
|
Previous version:
|
|
|
|
|
|
|
|
previous body
|
2021-01-29 17:22:07 +01:00
|
|
|
`,
|
|
|
|
},
|
|
|
|
} {
|
|
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
|
|
test.Equals(t, tc.exp, tc.task.FormatBody())
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestFieldFromBody(t *testing.T) {
|
|
|
|
for _, tc := range []struct {
|
2021-01-29 17:48:22 +01:00
|
|
|
name string
|
|
|
|
field string
|
|
|
|
body string
|
|
|
|
expValue string
|
|
|
|
expDirty bool
|
2021-01-29 17:22:07 +01:00
|
|
|
}{
|
|
|
|
{
|
|
|
|
name: "empty field",
|
|
|
|
body: `field: value`,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "empty body",
|
|
|
|
field: "field",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "not present",
|
|
|
|
field: "field",
|
|
|
|
body: "another: value",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "present",
|
|
|
|
field: "fieldb",
|
|
|
|
body: `
|
|
|
|
not a field at all
|
|
|
|
|
|
|
|
fielda: valuea
|
|
|
|
fieldb: valueb
|
|
|
|
fieldc: valuec
|
|
|
|
`,
|
2021-01-29 17:48:22 +01:00
|
|
|
expValue: "valueb",
|
2021-01-29 17:22:07 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "present twice",
|
|
|
|
field: "field",
|
|
|
|
body: `
|
|
|
|
field: valuea
|
|
|
|
field: valueb
|
|
|
|
`,
|
2021-01-29 17:48:22 +01:00
|
|
|
expValue: "valuea",
|
|
|
|
expDirty: true,
|
2021-01-29 17:22:07 +01:00
|
|
|
},
|
|
|
|
{
|
2021-01-29 19:40:46 +01:00
|
|
|
name: "colons",
|
2021-01-29 17:48:22 +01:00
|
|
|
field: "field",
|
|
|
|
body: "field:: val:ue",
|
|
|
|
expValue: ": val:ue",
|
2021-01-29 17:22:07 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "trim field",
|
|
|
|
field: "field",
|
|
|
|
body: " field : value",
|
2021-01-29 17:48:22 +01:00
|
|
|
expValue: "value",
|
2021-01-29 17:22:07 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "trim value",
|
|
|
|
field: "field",
|
|
|
|
body: "field: value ",
|
2021-01-29 17:48:22 +01:00
|
|
|
expValue: "value",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "quoted",
|
|
|
|
|
|
|
|
field: "field",
|
|
|
|
body: "> field: value",
|
|
|
|
expValue: "value",
|
2021-01-29 17:22:07 +01:00
|
|
|
},
|
2021-01-29 18:10:06 +01:00
|
|
|
{
|
|
|
|
name: "previous body",
|
|
|
|
field: "field",
|
|
|
|
body: `
|
|
|
|
field: valuea
|
|
|
|
|
|
|
|
Previous version:
|
|
|
|
|
|
|
|
field: valueb
|
|
|
|
`,
|
|
|
|
expValue: "valuea",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "quoted previous body",
|
|
|
|
field: "field",
|
|
|
|
body: `
|
|
|
|
field: valuea
|
|
|
|
|
|
|
|
> Previous version:
|
|
|
|
>
|
|
|
|
> field: valueb
|
|
|
|
`,
|
|
|
|
expValue: "valuea",
|
|
|
|
},
|
2021-01-29 17:22:07 +01:00
|
|
|
} {
|
|
|
|
t.Run(tc.name, func(t *testing.T) {
|
2021-01-29 17:48:22 +01:00
|
|
|
actValue, actDirty := task.FieldFromBody(tc.field, tc.body)
|
|
|
|
test.Equals(t, tc.expValue, actValue)
|
|
|
|
test.Equals(t, tc.expDirty, actDirty)
|
2021-01-29 17:22:07 +01:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestFieldFromSubject(t *testing.T) {
|
2021-01-30 15:25:25 +01:00
|
|
|
action := "action"
|
2021-01-31 08:22:31 +01:00
|
|
|
project := "project"
|
|
|
|
due := "due"
|
|
|
|
subjectOne := fmt.Sprintf("%s", action)
|
|
|
|
subjectTwo := fmt.Sprintf("%s - %s", project, action)
|
|
|
|
subjectThree := fmt.Sprintf("%s - %s - %s", due, project, action)
|
|
|
|
|
2021-01-29 17:22:07 +01:00
|
|
|
for _, tc := range []struct {
|
|
|
|
name string
|
|
|
|
field string
|
|
|
|
subject string
|
|
|
|
exp string
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
name: "empty field",
|
2021-01-30 15:25:25 +01:00
|
|
|
subject: action,
|
2021-01-29 17:22:07 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "empty subject",
|
|
|
|
field: task.FIELD_ACTION,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "unknown field",
|
|
|
|
field: "unknown",
|
2021-01-31 08:22:31 +01:00
|
|
|
subject: subjectOne,
|
2021-01-29 17:22:07 +01:00
|
|
|
},
|
|
|
|
{
|
2021-01-31 08:22:31 +01:00
|
|
|
name: "action with one",
|
2021-01-29 17:22:07 +01:00
|
|
|
field: task.FIELD_ACTION,
|
2021-01-31 08:22:31 +01:00
|
|
|
subject: subjectOne,
|
2021-01-30 15:25:25 +01:00
|
|
|
exp: action,
|
|
|
|
},
|
|
|
|
{
|
2021-01-31 08:22:31 +01:00
|
|
|
name: "action with with two",
|
2021-01-30 15:25:25 +01:00
|
|
|
field: task.FIELD_ACTION,
|
2021-01-31 08:22:31 +01:00
|
|
|
subject: subjectTwo,
|
2021-01-30 15:25:25 +01:00
|
|
|
exp: action,
|
|
|
|
},
|
|
|
|
{
|
2021-01-31 08:22:31 +01:00
|
|
|
name: "action with three",
|
2021-01-30 15:25:25 +01:00
|
|
|
field: task.FIELD_ACTION,
|
2021-01-31 08:22:31 +01:00
|
|
|
subject: subjectThree,
|
2021-01-30 15:25:25 +01:00
|
|
|
exp: action,
|
2021-01-29 17:22:07 +01:00
|
|
|
},
|
|
|
|
} {
|
|
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
|
|
test.Equals(t, tc.exp, task.FieldFromSubject(tc.field, tc.subject))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|