-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient_test.go
More file actions
107 lines (95 loc) · 2 KB
/
client_test.go
File metadata and controls
107 lines (95 loc) · 2 KB
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
package aidev
import (
"io/ioutil"
"log"
"testing"
)
func TestNewClient(t *testing.T) {
opts := defaultOptions()
opts.User = "admin"
opts.Password = "202cb962ac59075b964b07152d234b70"
// opts.Debug = true
cl := NewClient(opts)
if err := cl.RenewToken(); err != nil {
t.Fatal(err)
}
t.Run("GetToken", func(t *testing.T) {
token, err := cl.BaseAPI.GetToken("admin", "202cb962ac59075b964b07152d234b70")
if err != nil {
t.Error(err)
} else {
log.Println(token)
}
})
t.Run("GetDates", func(t *testing.T) {
list, err := cl.BaseAPI.GetDates("2020-07-05")
if err != nil {
t.Error(err)
}
log.Printf("%+v", list)
// Generate a sample QR code
qr, err := QRCode(list[0].Token)
if err != nil {
t.Fatal(err)
}
// Save temp file
_ = ioutil.WriteFile("docs/sample_qr.png", qr, 0400)
})
t.Run("GetCabins", func(t *testing.T) {
list, err := cl.BaseAPI.GetCabins()
if err != nil {
t.Error(err)
}
log.Printf("%+v", list)
})
t.Run("GetStudies", func(t *testing.T) {
res, err := cl.BaseAPI.GetStudies()
if err != nil {
t.Error(err)
} else {
log.Printf("%+v", res)
}
})
t.Run("GetAvailableTime", func(t *testing.T) {
res, err := cl.BaseAPI.GetAvailableTime("1", "2020-07-05")
if err != nil {
t.Error(err)
}
log.Printf("%+v", res)
})
t.Run("AddPerson", func(t *testing.T) {
id, err := cl.BaseAPI.AddPerson(PersonInput{
Name: "Rick Sanchez",
CURP: "MOSM780130HVZNTR07",
Age: "21",
Gender: "1",
})
if err != nil {
t.Error(err)
}
log.Println(id)
})
t.Run("AddAppointment", func(t *testing.T) {
res, err := cl.BaseAPI.AddAppointment(DateInput{
CabinID: "1",
StudyID: "1",
PersonID: "7",
Date: "2020-07-05",
HourStart: "11:00:00",
HourEnd: "12:00:00",
})
if err != nil {
t.Error(err)
} else {
log.Printf("%+v", res)
}
})
t.Run("GetResults", func(t *testing.T) {
res, err := cl.BaseAPI.GetResults(1)
if err != nil {
t.Error(err)
} else {
log.Printf("%+v", res)
}
})
}