-
Notifications
You must be signed in to change notification settings - Fork 47
/
integrationtest.sh
executable file
·137 lines (111 loc) · 3.78 KB
/
integrationtest.sh
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#!/bin/bash
# Just a quick smoke test to check nothing major is broken as a start of CI
# This script should only test commands work without crashing. Behavioural
# tests should use the go test system.
# pipe into cat to disable tty
# exit on error and print commands
set -x
set -e
# isolated db locations (repo2 is used for a sync target)
export DSTASK_GIT_REPO=$(mktemp --directory)
export UPSTREAM_BARE_REPO=$(mktemp --directory)
if [[ -d "dstask" ]]; then
rm -r dstask
fi
cleanup() {
set +x
set +e
rm -rf $DSTASK_GIT_REPO
rm -rf $UPSTREAM_BARE_REPO
rm dstask
}
trap cleanup EXIT
go build -o dstask -mod=vendor cmd/dstask/main.go
# initialse git repo
git -C $DSTASK_GIT_REPO init
git -C $DSTASK_GIT_REPO config user.email "you@example.com"
git -C $DSTASK_GIT_REPO config user.name "Test user"
git -C $UPSTREAM_BARE_REPO init --bare
# general task state management and commands
./dstask help
./dstask add test task +foo project:bar
./dstask start 1
./dstask stop 1
./dstask remove 1
./dstask add re-add add test task +foo project:bar
./dstask add another task
./dstask +foo
./dstask -foo
./dstask -project:foo
./dstask 2 done
./dstask undo
./dstask log something
./dstask +foo
./dstask note 1 this is a note
./dstask context +foo
./dstask next
./dstask 1 done
./dstask show-resolved
# TODO we set FAKE_PTY because we do not have a non-tty
# rendering scheme for show-projects
export DSTASK_FAKE_PTY=1
./dstask show-projects
unset DSTASK_FAKE_PTY
# -- to remove current context which is +foo
./dstask add -- unorganised task
./dstask show-unorganised
# we are in context project:bar, adding with another project should fail
./dstask context project:bar
! ./dstask add project:baz test
# ... however, bypassing the context with -- should work
./dstask add project:cheese test --
# test context listing with a context and no context
./dstask context
./dstask context none
./dstask context
# try to resolve a task with an incomplete tasklist: should fail
./dstask add a tasklist task -- "- [ ] incomplete task"
! ./dstask 2 done
# test template functions
./dstask add task to copy
./dstask add template:2 +copiedTask
./dstask template 5
# Task 5 should now be a template
./dstask show-templates +copiedTask
# copy Template with some modifications
./dstask add template:5 -copiedTask +copiedTemplate
./dstask show-open +copiedTemplate
# Create new template from CMD line.
./dstask template give me some things to do P1 +uniqueTag
./dstask show-templates +uniqueTag
# test import
./dstask import-tw < etc/taskwarrior-export.json
./dstask next
# test git command pass through
./dstask git status
# set the bare repository as upstream origin to test sync against, and then push to it
git -C $DSTASK_GIT_REPO remote add origin $UPSTREAM_BARE_REPO
git -C $DSTASK_GIT_REPO push origin master
git -C $DSTASK_GIT_REPO branch --set-upstream-to=origin/master master
./dstask sync
# cause independent changes (could be from separate downstream repositories,
# but its easier and equivalent to simulate this with a hard reset)
./dstask add eggs test task +foo project:bar
./dstask sync
./dstask git reset --hard HEAD~1
./dstask add bacon test task +foo project:bar
./dstask sync
# there should be no staged changes
git -C $DSTASK_GIT_REPO diff-index --quiet --cached HEAD --
# there should be no un-staged changes
git -C $DSTASK_GIT_REPO diff-files --quiet
# there should be no untracked files changes
test -z "$(git -C $DSTASK_GIT_REPO ls-files --others)"
# regression test: nil pointer dereference when showing by-week tables of zero length
./dstask show-resolved project:doesnotexist
# dstask should be able to create a git repo if it does not exist before
# executing command. Also help should work before initialisation (and should
# not init)
export DSTASK_GIT_REPO=$(mktemp --directory --dry-run)
./dstask help
./dstask add test