-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathsuite_test.go
97 lines (82 loc) · 1.93 KB
/
suite_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
package models
import (
"math/rand"
"strconv"
"testing"
"time"
"github.com/content-services/content-sources-backend/pkg/config"
"github.com/content-services/content-sources-backend/pkg/db"
"github.com/lib/pq"
"github.com/stretchr/testify/suite"
"gorm.io/gorm"
)
type ModelsSuite struct {
suite.Suite
db *gorm.DB
tx *gorm.DB
}
type RepositoryRpmSuite struct {
*ModelsSuite
}
type RepositoryPackageGroupSuite struct {
*ModelsSuite
}
type RepositoryEnvironmentSuite struct {
*ModelsSuite
}
// Not using seeds.RandomOrgId to avoid cycle dependency
var orgIDTest = strconv.Itoa(rand.Intn(99999999))
var accountIdTest = strconv.Itoa(rand.Intn(99999999))
var repoConfigTest1 = RepositoryConfiguration{
Base: Base{
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
},
Name: "Demo Repository Config",
Arch: config.X8664,
Versions: pq.StringArray{config.El7, config.El8, config.El9},
AccountID: accountIdTest,
OrgID: orgIDTest,
}
var repoTest1 = Repository{
Base: Base{
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
},
URL: "https://www.redhat.com",
LastIntrospectionTime: nil,
LastIntrospectionError: nil,
}
var rpmTest1 = Rpm{
Name: "test-package",
Arch: "x86_64",
Version: "1.0.0",
Release: "123",
Epoch: 0,
Summary: "Test package summary",
Checksum: "SHA256:b8229cf1a40dc02282aff718811b97f2330bcc62ad7657a885d18fb4cc1cdf29",
}
var packageGroupTest1 = PackageGroup{
ID: "test-package-group",
Name: "test-package-group",
Description: "",
PackageList: []string(nil),
}
var environmentTest1 = Environment{
ID: "test-environment",
Name: "test-environment",
Description: "",
}
func (suite *ModelsSuite) SetupTest() {
if err := db.Connect(); err != nil {
return
}
suite.db = db.DB
suite.tx = suite.db.Begin()
}
func (s *ModelsSuite) TearDownTest() {
s.tx.Rollback()
}
func TestModelsSuite(t *testing.T) {
suite.Run(t, new(ModelsSuite))
}