From 5c4fece605c2cb5a67131ba07c09c61a33a6323b Mon Sep 17 00:00:00 2001 From: Stanislav Fedii Date: Thu, 27 Feb 2020 11:18:38 -0500 Subject: [PATCH] Fixed attachment not being saved if allure-results folder does not exist. --- attachment.go | 1 + misc.go | 4 ++++ test_phase_container.go | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) 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)