github.com/grahambrereton-form3/tilt@v0.10.18/internal/k8s/target_test.go (about) 1 package k8s 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/assert" 7 "github.com/stretchr/testify/require" 8 9 "github.com/windmilleng/tilt/internal/k8s/testyaml" 10 ) 11 12 func TestNewTargetSortsK8sEntities(t *testing.T) { 13 entities := MustParseYAMLFromString(t, testyaml.OutOfOrderYaml) 14 targ, err := NewTarget("foo", entities, nil, nil, nil, nil) 15 require.NoError(t, err) 16 17 expectedKindOrder := []string{"PersistentVolume", "PersistentVolumeClaim", "ConfigMap", "Service", "StatefulSet", "Job", "Pod"} 18 19 actual, err := ParseYAMLFromString(targ.YAML) 20 require.NoError(t, err) 21 22 assertKindOrder(t, expectedKindOrder, actual, "result of `NewTarget` should contain sorted YAML") 23 24 expectedDisplayNames := []string{ 25 "postgres-pv-volume:persistentvolume", 26 "postgres-pv-claim:persistentvolumeclaim", 27 "postgres-config:configmap", 28 "postgres:service", 29 "postgres:statefulset", 30 "blorg-job:job", 31 "sleep:pod", 32 } 33 assert.Equal(t, expectedDisplayNames, targ.DisplayNames) 34 }