github.com/Datadog/cnab-go@v0.3.3-beta1.0.20191007143216-bba4b7e723d0/driver/kubernetes/kubernetes_integration_test.go (about) 1 // +build integration 2 3 package kubernetes 4 5 import ( 6 "bytes" 7 "testing" 8 9 "github.com/deislabs/cnab-go/bundle" 10 "github.com/deislabs/cnab-go/driver" 11 "github.com/stretchr/testify/assert" 12 ) 13 14 func TestDriver_Run_Integration(t *testing.T) { 15 namespace := "default" 16 k := &Driver{} 17 k.SetConfig(map[string]string{ 18 "KUBE_NAMESPACE": namespace, 19 }) 20 k.ActiveDeadlineSeconds = 60 21 22 cases := []struct { 23 name string 24 op *driver.Operation 25 output string 26 err error 27 }{ 28 { 29 name: "install", 30 op: &driver.Operation{ 31 Installation: "example", 32 Action: "install", 33 Image: bundle.InvocationImage{ 34 BaseImage: bundle.BaseImage{ 35 Image: "cnab/helloworld", 36 Digest: "sha256:55f83710272990efab4e076f9281453e136980becfd879640b06552ead751284", 37 }, 38 }, 39 Environment: map[string]string{ 40 "PORT": "3000", 41 }, 42 }, 43 output: "Port parameter was set to 3000\nInstall action\nAction install complete for example\n", 44 err: nil, 45 }, 46 } 47 48 for _, tc := range cases { 49 t.Run(tc.name, func(t *testing.T) { 50 var output bytes.Buffer 51 tc.op.Out = &output 52 if tc.op.Environment == nil { 53 tc.op.Environment = map[string]string{} 54 } 55 tc.op.Environment["CNAB_ACTION"] = tc.op.Action 56 tc.op.Environment["CNAB_INSTALLATION_NAME"] = tc.op.Installation 57 58 _, err := k.Run(tc.op) 59 60 if tc.err != nil { 61 assert.EqualError(t, err, tc.err.Error()) 62 } else { 63 assert.NoError(t, err) 64 } 65 assert.Equal(t, tc.output, output.String()) 66 }) 67 } 68 }