/
task_test.go
84 lines (71 loc) · 1.8 KB
/
task_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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package taskModel
import (
"encoding/json"
"testing"
"github.com/swsad-dalaotelephone/Server/modules/util"
)
func TestAddTask(t *testing.T) {
type Img struct {
Name string `json:"name"`
Link string `json:"link"`
}
img := &Img{"golang.png", "https://www.domain.com/avatar.png"}
icon, _ := json.Marshal(img)
task, res := AddTask(Task{
PublisherId: "xxx",
Type: "q",
Name: "dalkdj",
BriefInfo: "testteatlakjflksajf",
Contact: "123123",
Requirements: icon,
RequiredCount: 1})
t.Log(task, res)
}
func TestGetTask(t *testing.T) {
tasks1, err1 := GetTasksByStrKey("id", "q")
t.Log(tasks1, err1)
tasks2, err2 := GetTasksByStrKey("type", "q")
t.Log(tasks2[0], err2)
mapData := util.JsonToMap(tasks2[0].Requirements)
t.Log(mapData)
}
func TestGetUnfinishedTask(t *testing.T) {
tasks1, _ := GetUnfinishedTasks()
t.Log(len(tasks1))
}
func TestDeleteTask(t *testing.T) {
tasks, _ := GetTasksByStrKey("type", "q")
t.Log(len(tasks))
DeleteTaskById(tasks[0].Id)
tasks, _ = GetTasksByStrKey("type", "q")
t.Log(len(tasks))
}
func TestQuestionnaire(t *testing.T) {
tasks, _ := GetTasksByIntKey("type", 1)
for i := 0; i < len(tasks); i++ {
DeleteTaskById(tasks[i].Id)
}
type Img struct {
Name string `json:"name"`
Link string `json:"link"`
}
img := &Img{"golang.png", "https://www.domain.com/avatar.png"}
icon, _ := json.Marshal(img)
task, res := AddTask(Task{
PublisherId: "qqq",
Type: "q",
Name: "问卷test",
BriefInfo: "testteatlakjflksajf",
Contact: "123123",
RequiredCount: 1,
Questionnaire: Questionnaire{
Description: "dddddd",
Questions: icon}})
t.Log(res)
tasks, _ = GetTasksByStrKey("type", "q")
task = tasks[0]
task, _ = GetTaskDetail(task)
t.Log(task)
}
func TestDataCollection(t *testing.T) {
}