From e44bd4c61d9eb8a237328b669ee7c934e22f528f Mon Sep 17 00:00:00 2001 From: Marc Boudreau Date: Thu, 9 Mar 2023 13:46:54 -0500 Subject: [PATCH] Fix failing TestHCPLinkConnected Test (#19474) * replace use of os.Unsetenv in test with t.Setenv and remove t.Parallel from test that rely on env being modified. * experiment with using fromJSON function * revert previous experiment * including double quotes in the output value for the string ubuntu-latest * use go run to launch gofumpt --- .github/workflows/ci.yml | 2 +- Makefile | 2 +- command/server/hcp_link_config_test.go | 7 +++---- vault/external_tests/hcp_link/hcp_link_test.go | 1 - 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8565e3cc8e..a56634faf1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,7 @@ jobs: echo 'enterprise=1' >> $GITHUB_OUTPUT echo 'go-tags=ent enterprise' >> $GITHUB_OUTPUT else - echo 'runs-on=ubuntu-latest' >> $GITHUB_OUTPUT + echo 'runs-on="ubuntu-latest"' >> $GITHUB_OUTPUT echo 'enterprise=' >> $GITHUB_OUTPUT echo 'go-tags=' >> $GITHUB_OUTPUT fi diff --git a/Makefile b/Makefile index ac68d55f07..177ea044bb 100644 --- a/Makefile +++ b/Makefile @@ -217,7 +217,7 @@ fmtcheck: #@sh -c "'$(CURDIR)/scripts/gofmtcheck.sh'" fmt: - find . -name '*.go' | grep -v pb.go | grep -v vendor | xargs gofumpt -w + find . -name '*.go' | grep -v pb.go | grep -v vendor | xargs go run mvdan.cc/gofumpt -w semgrep: semgrep --include '*.go' --exclude 'vendor' -a -f tools/semgrep . diff --git a/command/server/hcp_link_config_test.go b/command/server/hcp_link_config_test.go index 3912a3cdab..51f5a5ec88 100644 --- a/command/server/hcp_link_config_test.go +++ b/command/server/hcp_link_config_test.go @@ -1,7 +1,6 @@ package server import ( - "os" "testing" "github.com/go-test/deep" @@ -10,9 +9,9 @@ import ( ) func TestHCPLinkConfig(t *testing.T) { - os.Unsetenv("HCP_CLIENT_ID") - os.Unsetenv("HCP_CLIENT_SECRET") - os.Unsetenv("HCP_RESOURCE_ID") + t.Setenv("HCP_CLIENT_ID", "") + t.Setenv("HCP_CLIENT_SECRET", "") + t.Setenv("HCP_RESOURCE_ID", "") config, err := LoadConfigFile("./test-fixtures/hcp_link_config.hcl") if err != nil { diff --git a/vault/external_tests/hcp_link/hcp_link_test.go b/vault/external_tests/hcp_link/hcp_link_test.go index daedd3ad6f..84a101a102 100644 --- a/vault/external_tests/hcp_link/hcp_link_test.go +++ b/vault/external_tests/hcp_link/hcp_link_test.go @@ -8,7 +8,6 @@ import ( ) func TestHCPLinkConnected(t *testing.T) { - t.Parallel() cluster := getTestCluster(t, 2) defer cluster.Cleanup()