Skip to content

Commit 34bf94b

Browse files
authored
Merge pull request #17 from securesign/update-structural-tests-for-deprecations
Update structural tests for deprecations
2 parents e4f6846 + 255c2a3 commit 34bf94b

File tree

5 files changed

+40
-2
lines changed

5 files changed

+40
-2
lines changed

.golangci.yml

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
linters-settings:
22
lll:
33
line-length: 170
4+
cyclop:
5+
max-complexity: 15
46
linters:
57
enable-all: true
68
disable:

test/acceptance/client_server_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ var _ = Describe("Client server", Ordered, func() {
167167
})
168168

169169
// verifyExecutable verifies that the executable file matches the target OS and architecture.
170-
func verifyExecutable(filePath, osName, arch string) error { //nolint:cyclop
170+
func verifyExecutable(filePath, osName, arch string) error {
171171
file, err := os.Open(filePath)
172172
if err != nil {
173173
return fmt.Errorf("failed to open file %s: %w", filePath, err)

test/acceptance/fbc_images_test.go

+12-1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ var _ = Describe("File-based catalog images", Ordered, func() {
4242
var bundles []olm.Bundle
4343
var channels []olm.Channel
4444
var packages []olm.Package
45+
var deprecation olm.Deprecation
4546

4647
It("extract catalog.json", func() {
4748
dir, err := os.MkdirTemp("", key)
@@ -65,6 +66,8 @@ var _ = Describe("File-based catalog images", Ordered, func() {
6566
channels = append(channels, typedObj)
6667
case olm.Package:
6768
packages = append(packages, typedObj)
69+
case olm.Deprecation:
70+
deprecation = typedObj
6871
}
6972
}
7073

@@ -88,7 +91,7 @@ var _ = Describe("File-based catalog images", Ordered, func() {
8891
})
8992

9093
It("verify channels", func() {
91-
expectedChannels := []string{"stable", "candidate-v1.1.0", "stable-v1.0"}
94+
expectedChannels := []string{"stable", "stable-v1.1", "stable-v1.0"}
9295
Expect(channels).To(HaveLen(len(expectedChannels)))
9396

9497
for _, channel := range channels {
@@ -110,6 +113,14 @@ var _ = Describe("File-based catalog images", Ordered, func() {
110113
Expect(exists).To(BeTrue(), fmt.Sprintf("olm bundle with %s hash not found", bundleImageHash))
111114
})
112115

116+
It("verify deprecations", func() {
117+
expectedDeprecations := []string{"stable-v1.0", "rhtas-operator.v1.0.0", "rhtas-operator.v1.0.1", "rhtas-operator.v1.0.2"}
118+
Expect(deprecation.Entries).To(HaveLen(len(expectedDeprecations)))
119+
120+
for _, entry := range deprecation.Entries {
121+
Expect(expectedDeprecations).To(ContainElement(entry.Reference.Name))
122+
}
123+
})
113124
},
114125
ocps)
115126
})

test/support/olm/catalog.go

+8
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@ func ParseCatalogJSON(reader io.Reader) ([]interface{}, error) {
4646
}
4747
result = append(result, bundle)
4848

49+
case "olm.deprecations":
50+
var deprecation Deprecation
51+
err = json.Unmarshal(rawJSON(raw), &deprecation)
52+
if err != nil {
53+
return nil, fmt.Errorf("failed to parse OLM deprecation: %w", err)
54+
}
55+
result = append(result, deprecation)
56+
4957
default:
5058
return nil, fmt.Errorf("unknown schema: %v", raw["schema"])
5159
}

test/support/olm/types.go

+17
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,20 @@ type Property struct {
3434
Type string `json:"type"`
3535
Value interface{} `json:"value"`
3636
}
37+
38+
// Deprecation Schema.
39+
type Deprecation struct {
40+
Schema string `json:"schema"`
41+
Package string `json:"package"`
42+
Entries []DeprecationEntry `json:"entries"`
43+
}
44+
45+
type DeprecationEntry struct {
46+
Message string `json:"message"`
47+
Reference Reference `json:"reference"`
48+
}
49+
50+
type Reference struct {
51+
Name string `json:"name"`
52+
Schema string `json:"schema"`
53+
}

0 commit comments

Comments
 (0)