pkg/generator: verify output of renderBuildFile in TestGenBuild
@@ -145,13 +145,35 @@ func TestGenTypes(t *testing.T) {
}
}
+const buildExp = `#!/usr/bin/env bash
+
+set -o errexit
+set -o nounset
+set -o pipefail
+
+if ! which go > /dev/null; then
+ echo "golang needs to be installed"
+ exit 1
+fi
+
+BIN_DIR="$(pwd)/tmp/_output/bin"
+mkdir -p ${BIN_DIR}
+PROJECT_NAME="play"
+REPO_PATH="github.com/coreos/play"
+BUILD_PATH="${REPO_PATH}/cmd/${PROJECT_NAME}"
+echo "building "${PROJECT_NAME}"..."
+GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o ${BIN_DIR}/${PROJECT_NAME} $BUILD_PATH
+`
+
func TestGenBuild(t *testing.T) {
buf := &bytes.Buffer{}
if err := renderBuildFile(buf, "github.com/coreos/play", "play"); err != nil {
t.Error(err)
return
}
- // TODO: add verification
+ if buildExp != buf.String() {
+ t.Errorf("want %v, got %v", buildExp, buf.String())
+ }
}
const boilerplateExp = `/*
