pkg/generator: verify outputs of coden in TestCodeGen
@@ -154,18 +154,52 @@ func TestGenBuild(t *testing.T) {
// TODO: add verification
}
+const boilerplateExp = `/*
+Copyright YEAR The play Authors
+
+Commercial software license.
+*/
+`
+
+const updateGeneratedExp = `#!/usr/bin/env bash
+
+set -o errexit
+set -o nounset
+set -o pipefail
+
+DOCKER_REPO_ROOT="/go/src/github.com/coreos/play"
+IMAGE=${IMAGE:-"gcr.io/coreos-k8s-scale-testing/codegen"}
+
+docker run --rm \
+ -v "$PWD":"$DOCKER_REPO_ROOT" \
+ -w "$DOCKER_REPO_ROOT" \
+ "$IMAGE" \
+ "/go/src/k8s.io/code-generator/generate-groups.sh" \
+ "all" \
+ "github.com/coreos/play/pkg/generated" \
+ "github.com/coreos/play/pkg/apis" \
+ "play:v1alpha1" \
+ --go-header-file "./hack/codegen/boilerplate.go.txt" \
+ $@
+.
+`
+
func TestCodeGen(t *testing.T) {
buf := &bytes.Buffer{}
if err := renderBoilerplateFile(buf, "play"); err != nil {
t.Error(err)
return
}
- // TODO: add verification
+ if boilerplateExp != buf.String() {
+ t.Errorf("want %v, got %v", boilerplateExp, buf.String())
+ }
buf = &bytes.Buffer{}
if err := renderUpdateGeneratedFile(buf, "github.com/coreos/play", "play", "v1alpha1"); err != nil {
t.Error(err)
return
}
- // TODO: add verification
+ if updateGeneratedExp != buf.String() {
+ t.Errorf("want %v, got %v", updateGeneratedExp, buf.String())
+ }
}
