-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathservice_test.go
76 lines (63 loc) · 1.57 KB
/
service_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
package rest_test
import (
"os"
"testing"
"github.com/openchirp/framework/rest"
)
func TestHost_ServiceCreateAndCheck(t *testing.T) {
// Get parameters from environment variables
frameworkUri := os.Getenv("FRAMEWORK_SERVER")
id := os.Getenv("USER_ID")
token := os.Getenv("USER_TOKEN")
host := rest.NewHost(frameworkUri)
if err := host.Login(id, token); err != nil {
t.Error("Error logging in:", err)
return
}
sInfo1, err := host.ServiceCreate("Test Service 1", "My Test Service 1", nil, nil)
if err != nil {
t.Error("Error creating service:", err)
return
}
t.Log(sInfo1)
sInfo2, err := host.RequestServiceInfo(sInfo1.ID)
if err != nil {
t.Error("Error creating service:", err)
return
}
t.Log(sInfo2)
if sInfo1.ID != sInfo2.ID {
t.Error("IDs don't match")
return
}
if sInfo1.Name != sInfo2.Name {
t.Error("Names don't match")
return
}
if sInfo1.Description != sInfo2.Description {
t.Error("Descriptions don't match")
return
}
}
func TestHost_ServiceCreateAndDelete(t *testing.T) {
// Get parameters from environment variables
frameworkUri := os.Getenv("FRAMEWORK_SERVER")
id := os.Getenv("USER_ID")
token := os.Getenv("USER_TOKEN")
host := rest.NewHost(frameworkUri)
if err := host.Login(id, token); err != nil {
t.Error("Error logging in:", err)
return
}
sInfo, err := host.ServiceCreate("Test Service 2", "My Test Service 2", nil, nil)
if err != nil {
t.Error("Error creating service:", err)
return
}
t.Log(sInfo)
err = host.ServiceDelete(sInfo.ID)
if err != nil {
t.Error("Error deleting service:", err)
return
}
}