mirror of
https://github.com/genuinetools/reg.git
synced 2024-09-12 06:11:03 -04:00
24 lines
871 B
Go
24 lines
871 B
Go
![]() |
package labels
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
|
||
|
"gotest.tools/assert"
|
||
|
is "gotest.tools/assert/cmp"
|
||
|
)
|
||
|
|
||
|
func TestForService(t *testing.T) {
|
||
|
labels := ForService("stack", "service")
|
||
|
|
||
|
assert.Check(t, is.Len(labels, 3))
|
||
|
assert.Check(t, is.Equal("stack", labels["com.docker.stack.namespace"]))
|
||
|
assert.Check(t, is.Equal("service", labels["com.docker.service.name"]))
|
||
|
assert.Check(t, is.Equal("stack-service", labels["com.docker.service.id"]))
|
||
|
}
|
||
|
|
||
|
func TestSelectorForStack(t *testing.T) {
|
||
|
assert.Check(t, is.Equal("com.docker.stack.namespace=demostack", SelectorForStack("demostack")))
|
||
|
assert.Check(t, is.Equal("com.docker.stack.namespace=stack,com.docker.service.name=service", SelectorForStack("stack", "service")))
|
||
|
assert.Check(t, is.Equal("com.docker.stack.namespace=stack,com.docker.service.name in (service1,service2)", SelectorForStack("stack", "service1", "service2")))
|
||
|
}
|