From b68a28865e0c81493dad5ea0c1ab935a86a3e156 Mon Sep 17 00:00:00 2001 From: Shreyas Goenka Date: Mon, 2 Dec 2024 14:27:32 +0100 Subject: [PATCH] Add comment for why we test two files for `bundle_uuid` --- libs/template/helpers_test.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libs/template/helpers_test.go b/libs/template/helpers_test.go index 802a8f6d55..6c476c658a 100644 --- a/libs/template/helpers_test.go +++ b/libs/template/helpers_test.go @@ -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) {