Esempio n. 1
0
func sel(kv []string) data.Selector {
	m := make(map[string]string)
	if len(kv)%2 != 0 {
		panic("Expected sel(k, v, ...)")
	}
	for i := 0; i < len(kv); i += 2 {
		m[kv[i]] = kv[i+1]
	}
	return data.Selector(m)
}
Esempio n. 2
0
func TestServiceSelect(t *testing.T) {
	st, err := runOpts(&addOpts{}, []string{
		"svc", "--image", "repo/image", "--port-fixed", "9000",
	})
	require.NoError(t, err)
	services := allServices(t, st)
	require.Len(t, services, 1)
	svc, err := st.GetService("svc", store.QueryServiceOptions{WithContainerRules: true})
	require.NoError(t, err)
	specs := svc.ContainerRules
	require.Len(t, specs, 1)
	spec := specs[0]
	require.NotNil(t, spec)
	require.Equal(t, DEFAULT_GROUP, spec.Name)
	require.Equal(t, data.Selector(map[string]string{
		"image": "repo/image",
	}), spec.Selector)
	require.Equal(t, data.AddressSpec{"fixed", 9000}, spec.AddressSpec)
}