-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutilities_test.go
113 lines (89 loc) · 2.16 KB
/
utilities_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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
package harper
import (
"testing"
"time"
)
func TestSystemStatus(t *testing.T) {
guest := randomID()
// try with standard super user
_, err := c.SystemInformation()
if err != nil {
t.Fatal(err)
}
// try with non-super user
p := Permission{}
p.SetSuperUser(false)
p.SetClusterUser(false)
role, err := c.AddRole(guest, p)
if err != nil {
t.Fatal(err)
}
defer c.DropRole(role.ID)
err = c.AddUser(guest, guest, role.Role, true)
if err != nil {
t.Fatal(err)
}
defer c.DropUser(guest)
guestClient := NewClient(DEFAULT_ENDPOINT, guest, guest)
_, err = guestClient.SystemInformation()
if e, ok := err.(*OperationError); ok && e.IsNotAuthorizedError() {
return
}
t.Fatal("expected SystemInfo call with guest user to fail")
}
func TestGetConfiguration(t *testing.T) {
if _, err := c.GetConfiguration(); err != nil {
t.Fatal(err)
}
}
func TestInstallNodeModule(t *testing.T) {
if _, err := c.AddCustomFunctionProject("my-project"); err != nil {
t.Fatal(err)
}
wait()
if _, err := c.InstallNodeModules([]string{"my-project"}, false); err != nil {
t.Fatal(err)
}
wait()
if _, err := c.DropComponent("my-project", ""); err != nil {
t.Fatal(err)
}
}
func TestDeleteRecordsBefore(t *testing.T) {
database := randomID()
table := randomID()
if err := c.CreateDatabase(database); err != nil {
t.Fatal(err)
}
wait()
if err := c.CreateTable(database, table, "id"); err != nil {
t.Log(err)
t.FailNow()
}
record := createTestRecord()
if _, err := c.Insert(database, table, []interface{}{record}); err != nil {
t.Fatal(err)
}
time.Sleep(time.Second * 5)
if message, err := c.DeleteRecordsBefore(time.Now(), database, table); err != nil {
t.Log(message)
t.Fatal(err)
}
time.Sleep(time.Second * 5)
resp, err := c.DescribeTable(database, table)
if err != nil {
t.Fatal(err)
}
t.Log(resp)
t.Log(resp.RecordCount)
if resp.RecordCount != 0 {
t.Fatal("There should not be any records left in the table")
}
}
func TestSetConfiguration(t *testing.T) {
var configuration = map[string]interface{}{}
configuration["LOGGING_ROTATION_ENABLED"] = true
if _, err := c.SetConfiguration(configuration); err != nil {
t.Fatal(err)
}
}