-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathtable_test.go
60 lines (49 loc) · 1.23 KB
/
table_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
// Copyright (c) 2023 Target Brands, Inc. All rights reserved.
//
// Use of this source code is governed by the LICENSE file in this repository.
package deployment
import (
"context"
"testing"
"github.com/DATA-DOG/go-sqlmock"
)
func TestDeployment_Engine_CreateDeploymentTable(t *testing.T) {
// setup types
_postgres, _mock := testPostgres(t)
defer func() { _sql, _ := _postgres.client.DB(); _sql.Close() }()
_mock.ExpectExec(CreatePostgresTable).WillReturnResult(sqlmock.NewResult(1, 1))
_sqlite := testSqlite(t)
defer func() { _sql, _ := _sqlite.client.DB(); _sql.Close() }()
// setup tests
tests := []struct {
failure bool
name string
database *engine
}{
{
failure: false,
name: "postgres",
database: _postgres,
},
{
failure: false,
name: "sqlite3",
database: _sqlite,
},
}
// run tests
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
err := test.database.CreateDeploymentTable(context.TODO(), test.name)
if test.failure {
if err == nil {
t.Errorf("CreateDeploymentTable for %s should have returned err", test.name)
}
return
}
if err != nil {
t.Errorf("CreateDeploymentTable for %s returned err: %v", test.name, err)
}
})
}
}