-
Notifications
You must be signed in to change notification settings - Fork 1
/
models_test.go
44 lines (36 loc) · 926 Bytes
/
models_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
package taskin
import (
"testing"
)
func TestTask(t *testing.T) {
task := Task{
Title: "Test Task",
Task: func(t *Task) error { return nil },
}
if task.Title != "Test Task" {
t.Errorf("Expected task title to be 'Test Task', got '%s'", task.Title)
}
err := task.Task(&task)
if err != nil {
t.Errorf("Expected task function to return nil, got '%s'", err.Error())
}
}
func TestRunner(t *testing.T) {
runner := Runner{
Task: Task{
Title: "Test Task",
Task: func(t *Task) error { return nil },
},
State: NotStarted,
}
if runner.State != NotStarted {
t.Errorf("Expected runner state to be 'NotStarted', got '%d'", runner.State)
}
if runner.Task.Title != "Test Task" {
t.Errorf("Expected task title to be 'Test Task', got '%s'", runner.Task.Title)
}
err := runner.Task.Task(&runner.Task)
if err != nil {
t.Errorf("Expected task function to return nil, got '%s'", err.Error())
}
}