Skip to content

Commit eb4ad74

Browse files
diff flag nil fix (#14763) (#23902)
[upstream:ae8beeadc9628e1753dea6ae8cd5e6b9171e783d] Signed-off-by: Modular Magician <[email protected]>
1 parent 792a1c7 commit eb4ad74

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

google/acctest/diff_utils.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ import (
3232
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
3333
)
3434

35+
const diffTag = "[Diff]"
36+
3537
func isReleaseDiffEnabled() bool {
3638
releaseDiff := os.Getenv("RELEASE_DIFF")
3739
return releaseDiff != ""
@@ -94,7 +96,7 @@ func InsertDiffSteps(c resource.TestCase, tempOutputFile *os.File, releaseProvid
9496
testStep.Config = ReformConfigWithProvider(ogConfig, localProviderName)
9597
fmt.Fprintf(tempOutputFile, "[DEBUG] Reformatted config: %s\n", testStep.Config)
9698
testStep.PreConfig = func() {
97-
fmt.Fprintf(tempOutputFile, "%s Step %d\n", diffFlag, countSteps)
99+
fmt.Fprintf(tempOutputFile, "%s Step %d\n", diffTag, countSteps)
98100
}
99101
if testStep.ExpectError == nil && !testStep.PlanOnly {
100102
newStep := resource.TestStep{
@@ -170,7 +172,7 @@ func ParseReleaseDiffOutput(output string) (isDiff bool) {
170172
lines := strings.Split(trimmedOutput, "\n")
171173
lastLine := lines[len(lines)-1]
172174

173-
isDiff = strings.HasPrefix(lastLine, diffFlag)
175+
isDiff = strings.HasPrefix(lastLine, diffTag)
174176

175177
return isDiff
176178
}
@@ -208,8 +210,8 @@ func writeOutputFileDeferFunction(tempOutputFile *os.File, failed bool) {
208210
if failed {
209211
// Check if the output line starts with "[Diff]"
210212
if isDiff {
211-
fmt.Fprintf(os.Stdout, "%s Breaking Change Detected] \n", diffFlag)
212-
fmt.Fprintf(diffFailureFile, "%s %s\n", diffFlag, testOutput)
213+
fmt.Fprintf(os.Stdout, "%s Breaking Change Detected] \n", diffTag)
214+
fmt.Fprintf(diffFailureFile, "%s %s\n", diffTag, testOutput)
213215
} else {
214216
fmt.Fprintf(regularFailureFile, testOutput)
215217
fmt.Fprintf(regularFailureFile, "FAILED --- %s\n", testOutput)

google/acctest/vcr_utils.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ var configs map[string]*transport_tpg.Config
6666

6767
var sources map[string]VcrSource
6868

69-
var diffFlag = "[Diff]"
70-
7169
// VcrSource is a source for a given VCR test with the value that seeded it
7270
type VcrSource struct {
7371
seed int64

0 commit comments

Comments
 (0)