1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/pkg/discovery/generator_test.go
Tibor Vass 59e55dcdd0 rm-gocheck: run goimports to compile successfully
goimports -w \
-- "./integration-cli/daemon" "./pkg/discovery" "./pkg/discovery/file" "./pkg/discovery/kv" "./pkg/discovery/memory" "./pkg/discovery/nodes" "./integration-cli" \
&& \
 gofmt -w -s \
-- "./integration-cli/daemon" "./pkg/discovery" "./pkg/discovery/file" "./pkg/discovery/kv" "./pkg/discovery/memory" "./pkg/discovery/nodes" "./integration-cli"

Signed-off-by: Tibor Vass <tibor@docker.com>
2019-09-09 21:06:12 +00:00

54 lines
1.7 KiB
Go

package discovery // import "github.com/docker/docker/pkg/discovery"
import (
"testing"
"gotest.tools/assert"
)
func (s *DiscoverySuite) TestGeneratorNotGenerate(c *testing.T) {
ips := Generate("127.0.0.1")
assert.Equal(c, len(ips), 1)
assert.Equal(c, ips[0], "127.0.0.1")
}
func (s *DiscoverySuite) TestGeneratorWithPortNotGenerate(c *testing.T) {
ips := Generate("127.0.0.1:8080")
assert.Equal(c, len(ips), 1)
assert.Equal(c, ips[0], "127.0.0.1:8080")
}
func (s *DiscoverySuite) TestGeneratorMatchFailedNotGenerate(c *testing.T) {
ips := Generate("127.0.0.[1]")
assert.Equal(c, len(ips), 1)
assert.Equal(c, ips[0], "127.0.0.[1]")
}
func (s *DiscoverySuite) TestGeneratorWithPort(c *testing.T) {
ips := Generate("127.0.0.[1:11]:2375")
assert.Equal(c, len(ips), 11)
assert.Equal(c, ips[0], "127.0.0.1:2375")
assert.Equal(c, ips[1], "127.0.0.2:2375")
assert.Equal(c, ips[2], "127.0.0.3:2375")
assert.Equal(c, ips[3], "127.0.0.4:2375")
assert.Equal(c, ips[4], "127.0.0.5:2375")
assert.Equal(c, ips[5], "127.0.0.6:2375")
assert.Equal(c, ips[6], "127.0.0.7:2375")
assert.Equal(c, ips[7], "127.0.0.8:2375")
assert.Equal(c, ips[8], "127.0.0.9:2375")
assert.Equal(c, ips[9], "127.0.0.10:2375")
assert.Equal(c, ips[10], "127.0.0.11:2375")
}
func (s *DiscoverySuite) TestGenerateWithMalformedInputAtRangeStart(c *testing.T) {
malformedInput := "127.0.0.[x:11]:2375"
ips := Generate(malformedInput)
assert.Equal(c, len(ips), 1)
assert.Equal(c, ips[0], malformedInput)
}
func (s *DiscoverySuite) TestGenerateWithMalformedInputAtRangeEnd(c *testing.T) {
malformedInput := "127.0.0.[1:x]:2375"
ips := Generate(malformedInput)
assert.Equal(c, len(ips), 1)
assert.Equal(c, ips[0], malformedInput)
}