-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathtasks_test.go
36 lines (31 loc) · 857 Bytes
/
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
package megos
import (
"reflect"
"testing"
)
func TestGetTaskByID_WithTask(t *testing.T) {
taskID := "Task2"
tasks := []Task{
{ID: "Task1", Name: "Test task one"},
{ID: "Task2", Name: "Test task two"},
{ID: "Task3", Name: "Test task three"},
}
if ta, err := client.GetTaskByID(tasks, taskID); !reflect.DeepEqual(ta, &tasks[1]) {
t.Errorf("Task is not the one as expected (%s). Expected %+v, got %+v", err, &tasks[1], ta)
}
}
func TestGetTaskByID_WithoutTask(t *testing.T) {
taskID := "Task4"
tasks := []Task{
{ID: "Task1", Name: "Test task one"},
{ID: "Task2", Name: "Test task two"},
{ID: "Task3", Name: "Test task three"},
}
ta, err := client.GetTaskByID(tasks, taskID)
if ta != nil {
t.Errorf("Task is not nil. Expected nil, got %+v", ta)
}
if err == nil {
t.Errorf("err is nil. Expected a string, got %s", err)
}
}