2017-11-20 09:30:52 -05:00
package labels
import (
"testing"
2018-03-05 18:53:52 -05:00
"github.com/gotestyourself/gotestyourself/assert"
is "github.com/gotestyourself/gotestyourself/assert/cmp"
2017-11-20 09:30:52 -05:00
)
func TestForService ( t * testing . T ) {
labels := ForService ( "stack" , "service" )
2018-03-05 18:53:52 -05:00
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" ] ) )
2017-11-20 09:30:52 -05:00
}
func TestSelectorForStack ( t * testing . T ) {
2018-03-05 18:53:52 -05:00
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" ) ) )
2017-11-20 09:30:52 -05:00
}