-
Notifications
You must be signed in to change notification settings - Fork 50
/
Copy pathmodify_test.go
64 lines (43 loc) · 1.93 KB
/
modify_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package integration
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestModifyTasksByID(t *testing.T) {
repo, cleanup := makeDstaskRepo(t)
defer cleanup()
program := testCmd(repo)
output, exiterr, success := program("add", "one", "+one")
assertProgramResult(t, output, exiterr, success)
output, exiterr, success = program("add", "two", "+two")
assertProgramResult(t, output, exiterr, success)
output, exiterr, success = program("add", "three", "+three")
assertProgramResult(t, output, exiterr, success)
output, exiterr, success = program("modify", "2", "3", "+extra")
assertProgramResult(t, output, exiterr, success)
output, exiterr, success = program("next")
assertProgramResult(t, output, exiterr, success)
tasks := unmarshalTaskArray(t, output)
assert.ElementsMatch(t, []string{"three", "extra"}, tasks[2].Tags, "extra tag added to task three")
assert.ElementsMatch(t, []string{"two", "extra"}, tasks[1].Tags, "extra tag added to task two")
assert.ElementsMatch(t, []string{"one"}, tasks[0].Tags, "task 1 not modified")
}
func TestModifyTasksInContext(t *testing.T) {
repo, cleanup := makeDstaskRepo(t)
defer cleanup()
program := testCmd(repo)
output, exiterr, success := program("add", "one", "+one")
assertProgramResult(t, output, exiterr, success)
output, exiterr, success = program("add", "two", "+two")
assertProgramResult(t, output, exiterr, success)
output, exiterr, success = program("add", "three", "+three")
assertProgramResult(t, output, exiterr, success)
output, exiterr, success = program("context", "+three")
assertProgramResult(t, output, exiterr, success)
output, exiterr, success = program("modify", "+extra")
assertProgramResult(t, output, exiterr, success)
output, exiterr, success = program("next")
assertProgramResult(t, output, exiterr, success)
tasks := unmarshalTaskArray(t, output)
assert.Equal(t, []string{"extra", "three"}, tasks[0].Tags, "tags should have been modified")
}