-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sort istags alphabetically during schema conversion
Signed-off-by: Michal Minář <[email protected]>
- Loading branch information
Michal Minář
committed
Nov 23, 2017
1 parent
21f535d
commit 0f6440d
Showing
3 changed files
with
48 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package v1 | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
|
||
"k8s.io/apimachinery/pkg/util/diff" | ||
kapi "k8s.io/kubernetes/pkg/api" | ||
|
||
newer "github.com/openshift/origin/pkg/image/apis/image" | ||
"github.com/openshift/origin/pkg/image/apis/image/v1" | ||
|
||
_ "github.com/openshift/origin/pkg/image/apis/image/install" | ||
) | ||
|
||
func TestImageStreamStatusConversionPreservesTags(t *testing.T) { | ||
in := &newer.ImageStreamStatus{ | ||
Tags: map[string]newer.TagEventList{ | ||
"v3.5.0": {}, | ||
"3.5.0": {}, | ||
}, | ||
} | ||
expOutVersioned := &v1.ImageStreamStatus{ | ||
Tags: []v1.NamedTagEventList{{Tag: "3.5.0"}, {Tag: "v3.5.0"}}, | ||
} | ||
|
||
outVersioned := v1.ImageStreamStatus{Tags: []v1.NamedTagEventList{}} | ||
err := kapi.Scheme.Convert(in, &outVersioned, nil) | ||
if err != nil { | ||
t.Fatalf("got unexpected error: %v", err) | ||
} | ||
if a, e := &outVersioned, expOutVersioned; !reflect.DeepEqual(a, e) { | ||
t.Fatalf("got unexpected output: %s", diff.ObjectDiff(&a, e)) | ||
} | ||
|
||
// convert back from v1 to internal scheme | ||
out := newer.ImageStreamStatus{} | ||
err = kapi.Scheme.Convert(&outVersioned, &out, nil) | ||
if err != nil { | ||
t.Fatalf("got unexpected error: %v", err) | ||
} | ||
if a, e := &out, in; !reflect.DeepEqual(a, e) { | ||
t.Fatalf("got unexpected output: %s", diff.ObjectDiff(&a, e)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters