Skip to content
This repository has been archived by the owner on May 3, 2022. It is now read-only.

Commit

Permalink
Add integration test
Browse files Browse the repository at this point in the history
This is behind a build flag. Usage:
    go test -tags=integration ./...
  • Loading branch information
jlegrone committed Jun 11, 2019
1 parent 474db9c commit 2d1ee4a
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions pkg/driver/kubernetes_integration_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// +build integration

package driver

import (
"bytes"
"testing"

"github.com/deislabs/cnab-go/driver"
"github.com/stretchr/testify/assert"
)

func TestKubernetesRun(t *testing.T) {
namespace := "default"
k := &KubernetesDriver{}
k.SetConfig(map[string]string{
"KUBE_NAMESPACE": namespace,
})
k.ActiveDeadlineSeconds = 60

cases := []struct {
name string
op *driver.Operation
output string
err error
}{
{
name: "install",
op: &driver.Operation{
Installation: "example",
Action: "install",
Image: "cnab/helloworld:latest",
Environment: map[string]string{
"PORT": "3000",
},
},
output: "Port parameter was set to 3000\nInstall action\nAction install complete for example\n",
err: nil,
},
}

for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
var output bytes.Buffer
tc.op.Out = &output
if tc.op.Environment == nil {
tc.op.Environment = map[string]string{}
}
tc.op.Environment["CNAB_ACTION"] = tc.op.Action
tc.op.Environment["CNAB_INSTALLATION_NAME"] = tc.op.Installation

err := k.Run(tc.op)

if tc.err != nil {
assert.EqualError(t, err, tc.err.Error())
} else {
assert.NoError(t, err)
}
assert.Equal(t, tc.output, output.String())
})
}
}

0 comments on commit 2d1ee4a

Please sign in to comment.