Skip to content

Commit

Permalink
chore: run all bpt tests (#2001)
Browse files Browse the repository at this point in the history
Co-authored-by: Andrew Peabody <[email protected]>
  • Loading branch information
bharathkkb and apeabody authored Dec 13, 2023
1 parent 9bd8903 commit a7eea94
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ exclude: |
dm/.*|
reports/.*|
cli/testdata/.*|
cli/bptest/.*
cli/bptest/.*|
infra/blueprint-test/.*.json
)$
repos:
- repo: https://github.com/renovatebot/pre-commit-hooks
Expand Down
4 changes: 4 additions & 0 deletions infra/blueprint-test/build/int.cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ steps:
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && prepare_environment']
dir: 'infra/blueprint-test'
- id: pkg-test
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'go test ./... -v']
dir: 'infra/blueprint-test/pkg'
- id: test
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'git config --global user.name "cft-test"; git config --global user.email "<>"; go test -v']
Expand Down
10 changes: 5 additions & 5 deletions infra/blueprint-test/pkg/golden/golden_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"github.com/stretchr/testify/assert"
)

const testProjectIDEnvVar = "TEST_GCLOUD_PROJECT"
const testProjectID = "foo"

func TestUpdate(t *testing.T) {
tests := []struct {
Expand Down Expand Up @@ -93,18 +93,18 @@ func TestJSONEq(t *testing.T) {
},
{
name: "sanitize projectID",
data: fmt.Sprintf("{\"foo\":\"bar\",\"baz\":{\"qux\":\"%s\"}}", os.Getenv(testProjectIDEnvVar)),
data: fmt.Sprintf("{\"foo\":\"bar\",\"baz\":{\"qux\":\"%s\"}}", testProjectID),
opts: []goldenFileOption{WithSanitizer(ProjectIDSanitizer(t))},
setProjectID: true,
eqPath: "baz",
want: "{\"qux\":\"PROJECT_ID\"}",
},
{
name: "no gcloud projectID set",
data: fmt.Sprintf("{\"foo\":\"bar\",\"baz\":{\"qux\":\"%s\"}}", os.Getenv(testProjectIDEnvVar)),
data: fmt.Sprintf("{\"foo\":\"bar\",\"baz\":{\"qux\":\"%s\"}}", testProjectID),
opts: []goldenFileOption{WithSanitizer(ProjectIDSanitizer(t))},
eqPath: "baz",
want: fmt.Sprintf("{\"qux\":\"%s\"}", os.Getenv(testProjectIDEnvVar)),
want: fmt.Sprintf("{\"qux\":\"%s\"}", testProjectID),
},
{
name: "multiple sanitizers quz",
Expand All @@ -121,7 +121,7 @@ func TestJSONEq(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
assert := assert.New(t)
if tt.setProjectID {
gcloud.Runf(t, "config set project %s", os.Getenv(testProjectIDEnvVar))
gcloud.Runf(t, "config set project %s", testProjectID)
defer gcloud.Run(t, "config unset project")
}
os.Setenv(gfUpdateEnvVar, "true")
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"foo":"bar"}
{"foo":"bar"}

0 comments on commit a7eea94

Please sign in to comment.