diff --git a/attachment.go b/attachment.go index 6f877d0..0d9639b 100644 --- a/attachment.go +++ b/attachment.go @@ -33,6 +33,7 @@ func AddAttachment(name string, mimeType MimeType, content []byte) error { func (a *attachment) writeAttachmentFile() error { resultsPathEnv := os.Getenv(resultsPathEnvKey) + ensureFolderCreated() if resultsPathEnv == "" { log.Printf("%s environment variable cannot be empty\n", resultsPathEnvKey) } diff --git a/misc.go b/misc.go index da6f30a..c36b133 100644 --- a/misc.go +++ b/misc.go @@ -123,3 +123,7 @@ func copy(src, dst string) (int64, error) { nBytes, err := io.Copy(destination, source) return nBytes, err } + +func ensureFolderCreated() { + createFolderOnce.Do(createFolderIfNotExists) +} diff --git a/test_phase_container.go b/test_phase_container.go index 0ff8d4c..bd390fb 100644 --- a/test_phase_container.go +++ b/test_phase_container.go @@ -123,7 +123,7 @@ func getCurrentTestPhaseObject(t *testing.T) *testPhaseContainer { } func (c container) writeResultsFile() error { - createFolderOnce.Do(createFolderIfNotExists) + ensureFolderCreated() copyEnvFileOnce.Do(copyEnvFileIfExists) j, err := json.Marshal(c)