Skip to content

Commit

Permalink
Merge pull request #28 from dailymotion/attachment_fix
Browse files Browse the repository at this point in the history
Fixed attachment not being saved if allure-results folder does not ex…
  • Loading branch information
ubermensch01 authored Mar 6, 2020
2 parents 3ce7241 + 5c4fece commit e00c8c6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions attachment.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
4 changes: 4 additions & 0 deletions misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
2 changes: 1 addition & 1 deletion test_phase_container.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit e00c8c6

Please sign in to comment.