Skip to content

Commit

Permalink
Add comment for why we test two files for bundle_uuid (#1949)
Browse files Browse the repository at this point in the history
## Changes
Addresses feedback from this thread
#1947 (comment)
  • Loading branch information
shreyas-goenka authored Dec 2, 2024
1 parent 94b221b commit f9d65f3
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions libs/template/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,16 @@ func TestTemplateBundleUuidFunction(t *testing.T) {
err = r.walk()
assert.NoError(t, err)

// We test the content of two generated files to ensure that the same UUID
// is used across all files generated by the template. Each file content is
// generated by a separate (*template.Template).Execute call, so testing different
// files ensures that the UUID is stable across all template execution calls.
copy := strings.Clone(bundleUuid)
assert.Len(t, r.files, 2)
c1 := strings.Trim(string(r.files[0].(*inMemoryFile).content), "\n\r")
assert.Equal(t, strings.Repeat(bundleUuid, 3), c1)
assert.Equal(t, strings.Repeat(copy, 3), c1)
c2 := strings.Trim(string(r.files[1].(*inMemoryFile).content), "\n\r")
assert.Equal(t, strings.Repeat(bundleUuid, 5), c2)
assert.Equal(t, strings.Repeat(copy, 5), c2)
}

func TestTemplateRegexpCompileFunction(t *testing.T) {
Expand Down

0 comments on commit f9d65f3

Please sign in to comment.