-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain_test.go
46 lines (40 loc) · 870 Bytes
/
main_test.go
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
36
37
38
39
40
41
42
43
44
45
46
package main
import (
"os"
"path/filepath"
"testing"
"github.com/stretchr/testify/assert"
)
func TestGetCacheFilePath(t *testing.T) {
// Setup temporary home directory
tmpHome, err := os.MkdirTemp("", "streakode-test-home")
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(tmpHome)
oldHome := os.Getenv("HOME")
os.Setenv("HOME", tmpHome)
defer os.Setenv("HOME", oldHome)
tests := []struct {
name string
profile string
expected string
}{
{
name: "Default Profile",
profile: "",
expected: filepath.Join(tmpHome, ".streakode.cache"),
},
{
name: "Custom Profile",
profile: "test",
expected: filepath.Join(tmpHome, ".streakode_test.cache"),
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
result := getCacheFilePath(tt.profile)
assert.Equal(t, tt.expected, result)
})
}
}