mirror of https://github.com/docker/docs.git
add unit test for the cleanup
Signed-off-by: Chanwit Kaewkasi <chanwit@gmail.com>
This commit is contained in:
parent
1b8166c7a5
commit
03f4650ac7
|
@ -3,14 +3,23 @@ package zookeeper
|
|||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/docker/swarm/discovery"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestInitialize(t *testing.T) {
|
||||
discovery := &ZkDiscoveryService{}
|
||||
assert.Error(t, discovery.Initialize("127.0.0.1/path", 0))
|
||||
assert.Equal(t, discovery.path, "/path")
|
||||
service := &ZkDiscoveryService{}
|
||||
assert.Error(t, service.Initialize("127.0.0.1/path", 0))
|
||||
assert.Equal(t, service.path, "/path")
|
||||
|
||||
assert.Error(t, discovery.Initialize("127.0.0.1,127.0.0.2,127.0.0.3/path", 0))
|
||||
assert.Equal(t, discovery.path, "/path")
|
||||
assert.Error(t, service.Initialize("127.0.0.1,127.0.0.2,127.0.0.3/path", 0))
|
||||
assert.Equal(t, service.path, "/path")
|
||||
}
|
||||
|
||||
func TestCreateNodes(t *testing.T) {
|
||||
service := &ZkDiscoveryService{}
|
||||
assert.Equal(t, service.createNodes(nil), []*discovery.Node{})
|
||||
nodes := service.createNodes([]string{"127.0.0.1", "127.0.0.2"})
|
||||
assert.Equal(t, nodes[0].String(), "http://127.0.0.1")
|
||||
assert.Equal(t, nodes[1].String(), "http://127.0.0.2")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue