-
Notifications
You must be signed in to change notification settings - Fork 257
Deprecation utests #1164
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
Deprecation utests #1164
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -280,6 +280,155 @@ func TestConvertToModel(t *testing.T) { | |
Bundles: []Bundle{newTestBundle("foo", "0.1.0")}, | ||
}, | ||
}, | ||
{ | ||
name: "Error/Deprecation/UnspecifiedPackage", | ||
assertion: hasError(`package name must be set for deprecation item 0`), | ||
grokspawn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
cfg: DeclarativeConfig{ | ||
Packages: []Package{ | ||
addPackageProperties( | ||
newTestPackage("foo", "alpha", svgSmallCircle), | ||
[]property.Property{ | ||
{Type: "owner", Value: json.RawMessage("{\"group\":\"abc.com\",\"name\":\"admin\"}")}, | ||
}, | ||
), | ||
}, | ||
Channels: []Channel{newTestChannel("foo", "alpha", ChannelEntry{Name: "foo.v0.1.0"})}, | ||
Bundles: []Bundle{newTestBundle("foo", "0.1.0")}, | ||
Deprecations: []Deprecation{ | ||
{Schema: SchemaDeprecation}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
name: "Error/Deprecation/OutOfBoundsBundle", | ||
assertion: hasError(`cannot deprecate bundle "foo.v2.0.0" for package "foo": bundle not found`), | ||
cfg: DeclarativeConfig{ | ||
Packages: []Package{ | ||
addPackageProperties( | ||
newTestPackage("foo", "alpha", svgSmallCircle), | ||
[]property.Property{ | ||
{Type: "owner", Value: json.RawMessage("{\"group\":\"abc.com\",\"name\":\"admin\"}")}, | ||
}, | ||
), | ||
}, | ||
Channels: []Channel{newTestChannel("foo", "alpha", ChannelEntry{Name: "foo.v0.1.0"})}, | ||
Bundles: []Bundle{newTestBundle("foo", "0.1.0")}, | ||
Deprecations: []Deprecation{ | ||
{ | ||
Schema: SchemaDeprecation, | ||
Package: "foo", | ||
Entries: []DeprecationEntry{ | ||
{Reference: PackageScopedReference{Schema: SchemaBundle, Name: "foo.v2.0.0"}, Message: "foo.v2.0.0 doesn't exist in the first place"}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
name: "Error/Deprecation/OutOfBoundsPackage", | ||
assertion: hasError(`cannot apply deprecations to an unknown package "nyarl"`), | ||
cfg: DeclarativeConfig{ | ||
Packages: []Package{ | ||
addPackageProperties( | ||
newTestPackage("foo", "alpha", svgSmallCircle), | ||
[]property.Property{ | ||
{Type: "owner", Value: json.RawMessage("{\"group\":\"abc.com\",\"name\":\"admin\"}")}, | ||
}, | ||
), | ||
}, | ||
Channels: []Channel{newTestChannel("foo", "alpha", ChannelEntry{Name: "foo.v0.1.0"})}, | ||
Bundles: []Bundle{newTestBundle("foo", "0.1.0")}, | ||
Deprecations: []Deprecation{ | ||
{ | ||
Schema: SchemaDeprecation, | ||
Package: "nyarl", | ||
}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
name: "Error/Deprecation/MultiplePerPackage", | ||
assertion: hasError(`expected a maximum of one deprecation per package: "foo"`), | ||
cfg: DeclarativeConfig{ | ||
Packages: []Package{ | ||
addPackageProperties( | ||
newTestPackage("foo", "alpha", svgSmallCircle), | ||
[]property.Property{ | ||
{Type: "owner", Value: json.RawMessage("{\"group\":\"abc.com\",\"name\":\"admin\"}")}, | ||
}, | ||
), | ||
}, | ||
Channels: []Channel{newTestChannel("foo", "alpha", ChannelEntry{Name: "foo.v0.1.0"})}, | ||
Bundles: []Bundle{newTestBundle("foo", "0.1.0")}, | ||
Deprecations: []Deprecation{ | ||
{ | ||
Schema: SchemaDeprecation, | ||
Package: "foo", | ||
Entries: []DeprecationEntry{ | ||
{Reference: PackageScopedReference{Schema: SchemaChannel, Name: "alpha"}, Message: "no more alpha channel"}, | ||
}, | ||
}, | ||
{ | ||
Schema: SchemaDeprecation, | ||
Package: "foo", | ||
Entries: []DeprecationEntry{ | ||
{Reference: PackageScopedReference{Schema: SchemaBundle, Name: "foo.v0.1.0"}, Message: "foo.v0.1.0 is dead. do another thing"}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
name: "Error/Deprecation/BadRefSchema", | ||
assertion: hasError(`cannot deprecate object declcfg.PackageScopedReference{Schema:"badschema", Name:"foo.v2.0.0"} referenced by entry 0 for package "foo": object schema unknown`), | ||
cfg: DeclarativeConfig{ | ||
Packages: []Package{ | ||
addPackageProperties( | ||
newTestPackage("foo", "alpha", svgSmallCircle), | ||
[]property.Property{ | ||
{Type: "owner", Value: json.RawMessage("{\"group\":\"abc.com\",\"name\":\"admin\"}")}, | ||
}, | ||
), | ||
}, | ||
Channels: []Channel{newTestChannel("foo", "alpha", ChannelEntry{Name: "foo.v0.1.0"})}, | ||
Bundles: []Bundle{newTestBundle("foo", "0.1.0")}, | ||
Deprecations: []Deprecation{ | ||
{ | ||
Schema: SchemaDeprecation, | ||
Package: "foo", | ||
Entries: []DeprecationEntry{ | ||
{Reference: PackageScopedReference{Schema: "badschema", Name: "foo.v2.0.0"}, Message: "foo.v2.0.0 doesn't exist in the first place"}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
name: "Error/Deprecation/DuplicateRef", | ||
assertion: hasError(`duplicate deprecation entry declcfg.PackageScopedReference{Schema:"olm.bundle", Name:"foo.v0.1.0"} for package "foo"`), | ||
cfg: DeclarativeConfig{ | ||
Packages: []Package{ | ||
addPackageProperties( | ||
newTestPackage("foo", "alpha", svgSmallCircle), | ||
[]property.Property{ | ||
{Type: "owner", Value: json.RawMessage("{\"group\":\"abc.com\",\"name\":\"admin\"}")}, | ||
}, | ||
), | ||
}, | ||
Channels: []Channel{newTestChannel("foo", "alpha", ChannelEntry{Name: "foo.v0.1.0"})}, | ||
Bundles: []Bundle{newTestBundle("foo", "0.1.0")}, | ||
Deprecations: []Deprecation{ | ||
{ | ||
Schema: SchemaDeprecation, | ||
Package: "foo", | ||
Entries: []DeprecationEntry{ | ||
{Reference: PackageScopedReference{Schema: SchemaBundle, Name: "foo.v0.1.0"}, Message: "foo.v0.1.0 is bad"}, | ||
{Reference: PackageScopedReference{Schema: SchemaBundle, Name: "foo.v0.1.0"}, Message: "foo.v0.1.0 is bad"}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
for _, s := range specs { | ||
|
@@ -291,7 +440,7 @@ func TestConvertToModel(t *testing.T) { | |
} | ||
|
||
func TestConvertToModelRoundtrip(t *testing.T) { | ||
expected := buildValidDeclarativeConfig(true) | ||
expected := buildValidDeclarativeConfig(validDeclarativeConfigSpec{IncludeUnrecognized: true, IncludeDeprecations: false}) // TODO: turn on deprecation when we have model-->declcfg conversion | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This function goes declcfg --> model --> declcfg and compares the start and finish products. We don't yet have backwards conversion, so this can't be enabled until #1162 lands. |
||
|
||
m, err := ConvertToModel(expected) | ||
require.NoError(t, err) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,7 @@ func TestConvertFromModel(t *testing.T) { | |
{ | ||
name: "Success", | ||
m: buildTestModel(), | ||
expectCfg: buildValidDeclarativeConfig(false), | ||
expectCfg: buildValidDeclarativeConfig(validDeclarativeConfigSpec{IncludeUnrecognized: false, IncludeDeprecations: false}), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. #1162 will make this |
||
}, | ||
} | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.