forked from go-squads/saga-scheduler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoperation_test.go
68 lines (51 loc) · 1.77 KB
/
operation_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 operationScheduler scheduler
type OperationSuite struct {
suite.Suite
}
func TestOperationSuite(t *testing.T) {
suite.Run(t, new(OperationSuite))
}
func (suite *OperationSuite) SetupSuite() {
operationScheduler = scheduler{}
err := operationScheduler.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 = operationScheduler.DB.Exec(clearQuery)
suite.NoError(err, "They should be no error")
_, err = operationScheduler.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")
_, err = operationScheduler.DB.Exec("INSERT INTO lxc (id, lxd_id, name, type, alias, is_deployed) VALUES ('very-unique-lxc-uuid','very-unique-lxd-uuid', 'test-lxc-1', 'image', '16.04', 0);")
suite.NoError(err, "They should be no error")
}
func (suite *OperationSuite) 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 *OperationSuite) TestGetOperationSuccessful() {
testLxc := lxc{
ID: "1",
}
err := testLxc.getLxc(lxcScheduler.DB)
suite.NoError(err, "They should be no error")
}
func (suite *OperationSuite) TestInsertOperationSuccessful() {
testOperation := operation{
ID: "very-unique-operation-uuid",
LxcID: "very-unique-lxc-uuid",
Status: "OK",
StatusCode: 200,
Description: "",
}
err := testOperation.insertOperation(operationScheduler.DB)
suite.NoError(err, "They should be no error")
}