|
|
@ -16,17 +16,18 @@ limitations under the License.
|
|
|
|
package chartutil
|
|
|
|
package chartutil
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
|
|
|
|
"encoding/json"
|
|
|
|
"testing"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
func TestVersionSet(t *testing.T) {
|
|
|
|
func TestVersionSet(t *testing.T) {
|
|
|
|
vs := NewVersionSet("v1", "extensions/v1beta1")
|
|
|
|
vs := NewVersionSet("v1", "apps/v1")
|
|
|
|
if d := len(vs); d != 2 {
|
|
|
|
if d := len(vs); d != 2 {
|
|
|
|
t.Errorf("Expected 2 versions, got %d", d)
|
|
|
|
t.Errorf("Expected 2 versions, got %d", d)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if !vs.Has("extensions/v1beta1") {
|
|
|
|
if !vs.Has("apps/v1") {
|
|
|
|
t.Error("Expected to find extensions/v1beta1")
|
|
|
|
t.Error("Expected to find apps/v1")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if vs.Has("Spanish/inquisition") {
|
|
|
|
if vs.Has("Spanish/inquisition") {
|
|
|
@ -49,3 +50,29 @@ func TestCapabilities(t *testing.T) {
|
|
|
|
t.Error("APIVersions should have v1")
|
|
|
|
t.Error("APIVersions should have v1")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func TestCapabilitiesJSONMarshal(t *testing.T) {
|
|
|
|
|
|
|
|
vs := NewVersionSet("v1", "apps/v1")
|
|
|
|
|
|
|
|
b, err := json.Marshal(vs)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
t.Fatal(err)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
expect := `["apps/v1","v1"]`
|
|
|
|
|
|
|
|
if string(b) != expect {
|
|
|
|
|
|
|
|
t.Fatalf("JSON marshaled semantic version not equal: expected %q, got %q", expect, string(b))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func TestCapabilitiesJSONUnmarshal(t *testing.T) {
|
|
|
|
|
|
|
|
in := `["apps/v1","v1"]`
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var vs VersionSet
|
|
|
|
|
|
|
|
if err := json.Unmarshal([]byte(in), &vs); err != nil {
|
|
|
|
|
|
|
|
t.Fatal(err)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if len(vs) != 2 {
|
|
|
|
|
|
|
|
t.Fatalf("JSON unmarshaled semantic version not equal: expected 2, got %d", len(vs))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|