forked from TrueCloudLab/distribution
registry/endpoint: make it testable
Signed-off-by: Vincent Batts <vbatts@redhat.com>
This commit is contained in:
parent
d81951fffa
commit
bcbb7e0c41
2 changed files with 44 additions and 10 deletions
27
docs/endpoint_test.go
Normal file
27
docs/endpoint_test.go
Normal file
|
@ -0,0 +1,27 @@
|
|||
package registry
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestEndpointParse(t *testing.T) {
|
||||
testData := []struct {
|
||||
str string
|
||||
expected string
|
||||
}{
|
||||
{IndexServerAddress(), IndexServerAddress()},
|
||||
{"http://0.0.0.0:5000", "http://0.0.0.0:5000/v1/"},
|
||||
{"0.0.0.0:5000", "https://0.0.0.0:5000/v1/"},
|
||||
}
|
||||
for _, td := range testData {
|
||||
e, err := newEndpoint(td.str)
|
||||
if err != nil {
|
||||
t.Errorf("%q: %s", td.str, err)
|
||||
}
|
||||
if e == nil {
|
||||
t.Logf("something's fishy, endpoint for %q is nil", td.str)
|
||||
continue
|
||||
}
|
||||
if e.String() != td.expected {
|
||||
t.Errorf("expected %q, got %q", td.expected, e.String())
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue