mirror of https://github.com/docker/docs.git
update tests
Signed-off-by: Victor Vieux <vieux@docker.com>
This commit is contained in:
parent
693fb0fcf1
commit
13b96828f2
|
|
@ -21,6 +21,7 @@ func NewNode(url string) (*Node, error) {
|
||||||
}
|
}
|
||||||
return &Node{host, port}, nil
|
return &Node{host, port}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n Node) String() string {
|
func (n Node) String() string {
|
||||||
return fmt.Sprintf("%s:%s", n.Host, n.Port)
|
return fmt.Sprintf("%s:%s", n.Host, n.Port)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,22 +6,32 @@ import (
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func TestNewNode(t *testing.T) {
|
||||||
|
node, err := NewNode("127.0.0.1:2375")
|
||||||
|
assert.Equal(t, node.Host, "127.0.0.1")
|
||||||
|
assert.Equal(t, node.Port, "2375")
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
_, err = NewNode("127.0.0.1")
|
||||||
|
assert.Error(t, err)
|
||||||
|
}
|
||||||
|
|
||||||
func TestParse(t *testing.T) {
|
func TestParse(t *testing.T) {
|
||||||
scheme, uri := parse("127.0.0.1")
|
scheme, uri := parse("127.0.0.1:2375")
|
||||||
assert.Equal(t, scheme, "nodes")
|
assert.Equal(t, scheme, "nodes")
|
||||||
assert.Equal(t, uri, "127.0.0.1")
|
assert.Equal(t, uri, "127.0.0.1:2375")
|
||||||
|
|
||||||
scheme, uri = parse("localhost")
|
scheme, uri = parse("localhost:2375")
|
||||||
assert.Equal(t, scheme, "nodes")
|
assert.Equal(t, scheme, "nodes")
|
||||||
assert.Equal(t, uri, "localhost")
|
assert.Equal(t, uri, "localhost:2375")
|
||||||
|
|
||||||
scheme, uri = parse("scheme://127.0.0.1")
|
scheme, uri = parse("scheme://127.0.0.1:2375")
|
||||||
assert.Equal(t, scheme, "scheme")
|
assert.Equal(t, scheme, "scheme")
|
||||||
assert.Equal(t, uri, "127.0.0.1")
|
assert.Equal(t, uri, "127.0.0.1:2375")
|
||||||
|
|
||||||
scheme, uri = parse("scheme://localhost")
|
scheme, uri = parse("scheme://localhost:2375")
|
||||||
assert.Equal(t, scheme, "scheme")
|
assert.Equal(t, scheme, "scheme")
|
||||||
assert.Equal(t, uri, "localhost")
|
assert.Equal(t, uri, "localhost:2375")
|
||||||
|
|
||||||
scheme, uri = parse("")
|
scheme, uri = parse("")
|
||||||
assert.Equal(t, scheme, "nodes")
|
assert.Equal(t, scheme, "nodes")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue