Skip to content

Commit

Permalink
added folder check
Browse files Browse the repository at this point in the history
  • Loading branch information
h0x0er committed Feb 3, 2022
1 parent 729140d commit e32b11e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
5 changes: 5 additions & 0 deletions annotation.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ func WriteAnnotation(message string) {
annotationMutex.Lock()
defer annotationMutex.Unlock()

dir := "/home/agent"
if _, err := os.Stat(dir); os.IsNotExist(err) {
_ = os.Mkdir(dir, 0644)
}

f, _ := os.OpenFile("/home/agent/annotation.log",
os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)

Expand Down
27 changes: 27 additions & 0 deletions annotation_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package main

import (
"os"
"testing"
)

func TestWriteAnnotation(t *testing.T) {
type args struct {
message string
}
tests := []struct {
name string
args args
}{
{name: "writing_annotation", args: args{message: "annotation1"}},
}
_, ciTest := os.LookupEnv("CI")
if ciTest {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
WriteAnnotation(tt.args.message)
})
}
}

}

0 comments on commit e32b11e

Please sign in to comment.