Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update structural tests for deprecations #17

Merged
merged 2 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
linters-settings:
lll:
line-length: 170
cyclop:
max-complexity: 15
linters:
enable-all: true
disable:
Expand Down
2 changes: 1 addition & 1 deletion test/acceptance/client_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ var _ = Describe("Client server", Ordered, func() {
})

// verifyExecutable verifies that the executable file matches the target OS and architecture.
func verifyExecutable(filePath, osName, arch string) error { //nolint:cyclop
func verifyExecutable(filePath, osName, arch string) error {
file, err := os.Open(filePath)
if err != nil {
return fmt.Errorf("failed to open file %s: %w", filePath, err)
Expand Down
13 changes: 12 additions & 1 deletion test/acceptance/fbc_images_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ var _ = Describe("File-based catalog images", Ordered, func() {
var bundles []olm.Bundle
var channels []olm.Channel
var packages []olm.Package
var deprecation olm.Deprecation

It("extract catalog.json", func() {
dir, err := os.MkdirTemp("", key)
Expand All @@ -65,6 +66,8 @@ var _ = Describe("File-based catalog images", Ordered, func() {
channels = append(channels, typedObj)
case olm.Package:
packages = append(packages, typedObj)
case olm.Deprecation:
deprecation = typedObj
}
}

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

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

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

It("verify deprecations", func() {
expectedDeprecations := []string{"stable-v1.0", "rhtas-operator.v1.0.0", "rhtas-operator.v1.0.1", "rhtas-operator.v1.0.2"}
Expect(deprecation.Entries).To(HaveLen(len(expectedDeprecations)))

for _, entry := range deprecation.Entries {
Expect(expectedDeprecations).To(ContainElement(entry.Reference.Name))
}
})
},
ocps)
})
8 changes: 8 additions & 0 deletions test/support/olm/catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ func ParseCatalogJSON(reader io.Reader) ([]interface{}, error) {
}
result = append(result, bundle)

case "olm.deprecations":
var deprecation Deprecation
err = json.Unmarshal(rawJSON(raw), &deprecation)
if err != nil {
return nil, fmt.Errorf("failed to parse OLM deprecation: %w", err)
}
result = append(result, deprecation)

default:
return nil, fmt.Errorf("unknown schema: %v", raw["schema"])
}
Expand Down
17 changes: 17 additions & 0 deletions test/support/olm/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,20 @@ type Property struct {
Type string `json:"type"`
Value interface{} `json:"value"`
}

// Deprecation Schema.
type Deprecation struct {
Schema string `json:"schema"`
Package string `json:"package"`
Entries []DeprecationEntry `json:"entries"`
}

type DeprecationEntry struct {
Message string `json:"message"`
Reference Reference `json:"reference"`
}

type Reference struct {
Name string `json:"name"`
Schema string `json:"schema"`
}
Loading