mirror of https://github.com/knative/pkg.git
unit test to ensure semantic equality func is registered for apis.URL (#988)
This commit is contained in:
parent
8c11c24324
commit
f72610ea73
|
|
@ -20,6 +20,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"k8s.io/apimachinery/pkg/api/equality"
|
||||
)
|
||||
|
||||
func TestParseURL(t *testing.T) {
|
||||
|
|
@ -590,7 +591,7 @@ func TestResolveReference(t *testing.T) {
|
|||
mustParse := func(url string) *URL {
|
||||
u, err := ParseURL(url)
|
||||
if err != nil {
|
||||
t.Fatalf("Parse(%q) got err %v", url, err)
|
||||
t.Fatalf("ParseURL(%q) got err %v", url, err)
|
||||
}
|
||||
return u
|
||||
}
|
||||
|
|
@ -603,3 +604,28 @@ func TestResolveReference(t *testing.T) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestSemanticEquality(t *testing.T) {
|
||||
u1, err := ParseURL("https://user:password@example.com")
|
||||
if err != nil {
|
||||
t.Fatalf("ParseURL() got err %v", err)
|
||||
}
|
||||
|
||||
u2, err := ParseURL("https://user:password@example.com")
|
||||
if err != nil {
|
||||
t.Fatalf("ParseURL() got err %v", err)
|
||||
}
|
||||
|
||||
u3, err := ParseURL("https://another-user:password@example.com")
|
||||
if err != nil {
|
||||
t.Fatalf("ParseURL() got err %v", err)
|
||||
}
|
||||
|
||||
if !equality.Semantic.DeepEqual(u1, u2) {
|
||||
t.Errorf("expected urls to be equivalent")
|
||||
}
|
||||
|
||||
if equality.Semantic.DeepEqual(u1, u3) {
|
||||
t.Errorf("expected urls to be different")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue