-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtasks_test.go
62 lines (51 loc) · 1.32 KB
/
tasks_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
package alvtimeclient
import (
"testing"
)
func createTestAlvtimeClient() *AlvtimeClient {
testDomain := "http://alvtime-web-api"
testToken := "5801gj90-jf39-5j30-fjk3-480fj39kl409"
c, _ := New(testDomain, testToken)
return c
}
func TestGetTasks(t *testing.T) {
c := createTestAlvtimeClient()
tasks, err := c.GetTasks()
if err != nil {
t.Error(err)
}
length := len(tasks)
if length <= 0 {
t.Errorf("Length of tasks array is %v, not above 0", length)
}
}
func TestEditFavoriteTasks(t *testing.T) {
c := createTestAlvtimeClient()
tasks, err := c.GetTasks()
if err != nil {
t.Error(err)
}
var tasksToEdit = []Task{tasks[0], tasks[1]}
tasksToEditCopy := make([]Task, len(tasksToEdit))
copy(tasksToEditCopy, tasksToEdit)
tasksToEdit[0].Favorite = !tasksToEdit[0].Favorite
tasksToEdit[1].Favorite = !tasksToEdit[1].Favorite
editedTasks, err := c.EditFavoriteTasks(tasksToEdit)
if err != nil {
t.Error(err)
}
length := len(editedTasks)
expectedLength := 2
if length != expectedLength {
t.Errorf("Length of tasks array is %v, not the expected %v", length, expectedLength)
}
for _, taskToEditCopy := range tasksToEditCopy {
for _, editedTask := range editedTasks {
if taskToEditCopy.ID == editedTask.ID {
if taskToEditCopy.Favorite == editedTask.Favorite {
t.Errorf("hei")
}
}
}
}
}