2018-02-20 10:31:08 -05:00
|
|
|
package kubernetes
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
composetypes "github.com/docker/cli/cli/compose/types"
|
|
|
|
apiv1beta1 "github.com/docker/cli/kubernetes/compose/v1beta1"
|
2017-12-21 16:27:57 -05:00
|
|
|
"github.com/google/go-cmp/cmp"
|
2018-03-05 18:53:52 -05:00
|
|
|
"github.com/gotestyourself/gotestyourself/assert"
|
2018-02-20 10:31:08 -05:00
|
|
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestLoadStack(t *testing.T) {
|
2018-02-21 12:31:52 -05:00
|
|
|
s, err := LoadStack("foo", composetypes.Config{
|
|
|
|
Version: "3.1",
|
2018-02-20 10:31:08 -05:00
|
|
|
Filename: "banana",
|
|
|
|
Services: []composetypes.ServiceConfig{
|
|
|
|
{
|
|
|
|
Name: "foo",
|
|
|
|
Image: "foo",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "bar",
|
|
|
|
Image: "bar",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
2018-03-05 18:53:52 -05:00
|
|
|
assert.NilError(t, err)
|
|
|
|
assert.DeepEqual(t, &apiv1beta1.Stack{
|
2018-02-20 10:31:08 -05:00
|
|
|
ObjectMeta: metav1.ObjectMeta{
|
|
|
|
Name: "foo",
|
|
|
|
},
|
|
|
|
Spec: apiv1beta1.StackSpec{
|
2017-12-21 16:27:57 -05:00
|
|
|
ComposeFile: `version: "3.1"
|
2018-02-20 10:31:08 -05:00
|
|
|
services:
|
|
|
|
bar:
|
|
|
|
image: bar
|
|
|
|
foo:
|
|
|
|
image: foo
|
2018-02-21 12:31:52 -05:00
|
|
|
networks: {}
|
2018-02-20 10:31:08 -05:00
|
|
|
volumes: {}
|
2018-02-21 12:31:52 -05:00
|
|
|
secrets: {}
|
|
|
|
configs: {}
|
2017-12-21 16:27:57 -05:00
|
|
|
`,
|
2018-02-20 10:31:08 -05:00
|
|
|
},
|
2017-12-21 16:27:57 -05:00
|
|
|
}, s, cmpKubeAPITime)
|
2018-02-20 10:31:08 -05:00
|
|
|
}
|
2017-12-21 16:27:57 -05:00
|
|
|
|
|
|
|
// TODO: this can be removed when k8s.io/apimachinery is updated to > 1.9.0
|
|
|
|
var cmpKubeAPITime = cmp.Comparer(func(x, y *metav1.Time) bool {
|
|
|
|
if x == nil || y == nil {
|
|
|
|
return x == y
|
|
|
|
}
|
|
|
|
return x.Time.Equal(y.Time)
|
|
|
|
})
|