-
Notifications
You must be signed in to change notification settings - Fork 258
Expand file tree
/
Copy pathlog.go
More file actions
35 lines (28 loc) · 751 Bytes
/
log.go
File metadata and controls
35 lines (28 loc) · 751 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package e2e
import (
"os"
"path/filepath"
"testing"
"github.com/Azure/agentbaker/e2e/config"
)
func testDir(t testing.TB) string {
return filepath.Join(config.Config.E2ELoggingDir, t.Name())
}
func writeToFile(t testing.TB, fileName, content string) error {
dirPath := testDir(t)
// Create the directory if it doesn't exist
if err := os.MkdirAll(dirPath, 0755); err != nil {
return err
}
fullPath := filepath.Join(dirPath, fileName)
return os.WriteFile(fullPath, []byte(content), 0600)
}
func dumpFileMapToDir(t testing.TB, files map[string]string) error {
for fileName, contents := range files {
fileName = filepath.Base(fileName)
if err := writeToFile(t, fileName, contents); err != nil {
return err
}
}
return nil
}