-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathlxc_test.go
68 lines (52 loc) · 1.49 KB
/
lxc_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
package main
import (
"testing"
"github.com/stretchr/testify/suite"
)
var lxcScheduler scheduler
type LxcSuite struct {
suite.Suite
}
func TestLxcSuite(t *testing.T) {
suite.Run(t, new(LxcSuite))
}
func (suite *LxcSuite) SetupSuite() {
lxcScheduler = scheduler{}
err := lxcScheduler.initialize("postgres", "postgres", "saga", "localhost", "5432", "disable")
suite.NoError(err, "They should be no error")
clearQuery := `DELETE FROM operation;
DELETE FROM lxc;
DELETE FROM lxd;`
_, err = lxcScheduler.DB.Exec(clearQuery)
suite.NoError(err, "They should be no error")
_, err = lxcScheduler.DB.Exec("INSERT INTO lxd (id, name, address) VALUES ('very-unique-lxd-uuid', 'test-lxd', 'test.gojek.com');")
suite.NoError(err, "They should be no error")
}
func (suite *LxcSuite) TearDownSuite() {
clearQuery := `DELETE FROM operation;
DELETE FROM lxc;
DELETE FROM lxd;`
_, err := lxcScheduler.DB.Exec(clearQuery)
suite.NoError(err, "They should be no error")
}
func (suite *LxcSuite) TestGetLxcSuccessful() {
testLxc := lxc{
ID: "1",
}
err := testLxc.getLxc(lxcScheduler.DB)
suite.NoError(err, "They should be no error")
}
func (suite *LxcSuite) TestInsertLxcSuccessful() {
testLxc := lxc{
ID: "very-unique-lxc-uuid",
LxdID: "very-unique-lxd-uuid",
Name: "test-lxc-1",
Type: "image",
Alias: "16.04",
Address: "",
Description: "",
IsDeployed: 1,
}
err := testLxc.insertLxc(lxcScheduler.DB)
suite.NoError(err, "They should be no error")
}