mirror of https://github.com/helm/helm
ParseType parses a string and returns a *registry.Type. The client code currently uses this functionality, but it seems like it's better treated as part of the registry library, rather than as a one-off.pull/173/head
parent
2141263e84
commit
7e25d67c61
@ -0,0 +1,28 @@
|
||||
package registry
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestParseType(t *testing.T) {
|
||||
// TODO: Are there some real-world examples we want to valide here?
|
||||
tests := map[string]*Type{
|
||||
"foo": &Type{Name: "foo"},
|
||||
"foo:v1": &Type{Name: "foo", Version: "v1"},
|
||||
"github.com/foo": &Type{Name: "foo", Collection: "github.com"},
|
||||
"github.com/foo:v1.2.3": &Type{Name: "foo", Collection: "github.com", Version: "v1.2.3"},
|
||||
}
|
||||
|
||||
for in, expect := range tests {
|
||||
out := ParseType(in)
|
||||
if out.Name != expect.Name {
|
||||
t.Errorf("Expected name to be %q, got %q", expect.Name, out.Name)
|
||||
}
|
||||
if out.Version != expect.Version {
|
||||
t.Errorf("Expected version to be %q, got %q", expect.Version, out.Version)
|
||||
}
|
||||
if out.Collection != expect.Collection {
|
||||
t.Errorf("Expected collection to be %q, got %q", expect.Collection, out.Collection)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in new issue