Skip to content

Commit

Permalink
Fixing isReplacementAvailableIn logic when field available in is empty (
Browse files Browse the repository at this point in the history
#516)

* Fixing isReplacementAvailableIn logic when field available in is empty

* Fixing tests

* Fixing tests

* Fixed tests
  • Loading branch information
jdesouza authored Nov 9, 2023
1 parent 0f1ca9b commit 7d28833
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
9 changes: 5 additions & 4 deletions pkg/api/output_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ var testOutputDeprecatedNotRemoved = &Output{
ReplacementAPI: "none",
Component: "foo",
},
ReplacementAvailable: false,
}

func init() {
Expand All @@ -109,7 +110,7 @@ func ExampleInstance_DisplayOutput_normal() {
// NAME-------------------- KIND-------- VERSION------------- REPLACEMENT-- REMOVED-- DEPRECATED-- REPL AVAIL--
// some name one----------- Deployment-- extensions/v1beta1-- apps/v1------ true----- true-------- true--------
// some name two----------- Deployment-- extensions/v1beta1-- apps/v1------ true----- true-------- true--------
// deprecated not removed-- Deployment-- apps/v1------------- none--------- false---- true-------- true--------
// deprecated not removed-- Deployment-- apps/v1------------- none--------- false---- true-------- false-------
}

func ExampleInstance_DisplayOutput_onlyShowRemoved() {
Expand Down Expand Up @@ -411,7 +412,7 @@ func TestGetReturnCode(t *testing.T) {
ignoreRemovals: false,
ignoreReplacementUnavailable: false,
},
want: 2,
want: 4,
},
{
name: "version is deprecated ignore deprecations",
Expand All @@ -429,7 +430,7 @@ func TestGetReturnCode(t *testing.T) {
ignoreRemovals: false,
ignoreReplacementUnavailable: false,
},
want: 0,
want: 4,
},
{
name: "version is removed",
Expand All @@ -447,7 +448,7 @@ func TestGetReturnCode(t *testing.T) {
ignoreRemovals: false,
ignoreReplacementUnavailable: false,
},
want: 3,
want: 4,
},
{
name: "version is removed and replacement is unavailable",
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ func (v *Version) isReplacementAvailableIn(targetVersions map[string]string) boo
}

if v.ReplacementAvailableIn == "" {
return true
return false
}

targetVersion, ok := targetVersions[v.Component]
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/versions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ func TestVersion_isReplacementAvailableIn(t *testing.T) {
targetVersions: map[string]string{"foo": "v1.16.0"},
component: "foo",
replacementAvailableIn: "",
want: true,
want: false,
},
{
name: "targetVersions not included for component",
Expand Down

0 comments on commit 7d28833

Please sign in to comment.