Skip to content

Commit 937fef2

Browse files
committed
RHINENG-21786: update test to JSONSlice datatype
1 parent 1b91223 commit 937fef2

2 files changed

Lines changed: 11 additions & 9 deletions

File tree

manager/controllers/advisory_detail_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99

1010
log "github.com/sirupsen/logrus"
1111
"github.com/stretchr/testify/assert"
12+
"gorm.io/datatypes"
1213
)
1314

1415
func TestAdvisoryDetailDefault(t *testing.T) {
@@ -32,11 +33,11 @@ func (r *AdvisoryDetailResponse) checkRH9Fields(t *testing.T) {
3233
assert.Equal(t, "2018-09-22 20:00:00 +0000 UTC", r.Data.Attributes.ModifiedDate.String())
3334
assert.Equal(t, 2, len(r.Data.Attributes.Packages))
3435
assert.Equal(
35-
t, packages{"firefox-77.0.1-1.fc31.x86_64", "firefox-77.0.1-1.fc31.s390"},
36+
t, datatypes.JSONSlice[string]{"firefox-77.0.1-1.fc31.x86_64", "firefox-77.0.1-1.fc31.s390"},
3637
r.Data.Attributes.Packages,
3738
)
3839
assert.Equal(t, false, r.Data.Attributes.RebootRequired)
39-
assert.Equal(t, []string{"8.2", "8.4"}, r.Data.Attributes.ReleaseVersions)
40+
assert.Equal(t, datatypes.JSONSlice[string]{"8.2", "8.4"}, r.Data.Attributes.ReleaseVersions)
4041
assert.Nil(t, r.Data.Attributes.Severity)
4142
}
4243

tasks/vmaas_sync/advisory_sync_test.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212

1313
"github.com/bytedance/sonic"
1414
"github.com/stretchr/testify/assert"
15+
"gorm.io/datatypes"
1516
)
1617

1718
func TestInit(_ *testing.T) {
@@ -97,21 +98,21 @@ func TestParseAdvisories(t *testing.T) {
9798
"ER1": {
9899
Updated: "2004-09-02T00:00:00+00:00",
99100
Severity: "",
100-
ReferenceList: &[]string{},
101+
ReferenceList: []string{},
101102
Issued: "2004-09-02T00:00:00+00:00",
102103
Description: "DESC",
103104
Solution: utils.PtrString("SOL"),
104105
Summary: "SUM",
105106
URL: utils.PtrString("URL"),
106107
Synopsis: "SYN",
107-
CveList: utils.PtrSliceString([]string{"CVE-1", "CVE-2", "CVE-3"}),
108-
BugzillaList: &[]string{},
108+
CveList: []string{"CVE-1", "CVE-2", "CVE-3"},
109+
BugzillaList: []string{},
109110
PackageList: []string{},
110-
SourcePackageList: &[]string{},
111+
SourcePackageList: []string{},
111112
Type: "bugfix",
112113
ThirdParty: new(bool),
113114
RequiresReboot: true,
114-
ReleaseVersions: utils.PtrSliceString([]string{"8.0", "8.1"}),
115+
ReleaseVersions: []string{"8.0", "8.1"},
115116
},
116117
}
117118

@@ -132,8 +133,8 @@ func TestParseAdvisories(t *testing.T) {
132133
assert.Equal(t, 2, adv.AdvisoryTypeID)
133134
assert.Equal(t, 2, adv.AdvisoryTypeID)
134135
assert.Equal(t, true, adv.RebootRequired)
135-
assert.Equal(t, `["CVE-1","CVE-2","CVE-3"]`, string(adv.CveList))
136-
assert.Equal(t, `["8.0","8.1"]`, string(adv.ReleaseVersions))
136+
assert.Equal(t, datatypes.JSONSlice[string]{"CVE-1", "CVE-2", "CVE-3"}, adv.CveList)
137+
assert.Equal(t, datatypes.JSONSlice[string]{"8.0", "8.1"}, adv.ReleaseVersions)
137138
}
138139

139140
func TestSaveAdvisories(t *testing.T) {

0 commit comments

Comments
 (0)