MCPcopy Create free account
hub / github.com/astercloud/aster / TestNewFilePreferenceStorage

Function TestNewFilePreferenceStorage

pkg/memory/preference_storage_test.go:11–32  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

9)
10
11func TestNewFilePreferenceStorage(t *testing.T) {
12 tmpDir := filepath.Join(os.TempDir(), "test-preferences")
13 defer func() {
14 if err := os.RemoveAll(tmpDir); err != nil {
15 t.Errorf("Failed to remove temp dir: %v", err)
16 }
17 }()
18
19 storage, err := NewFilePreferenceStorage(tmpDir)
20 if err != nil {
21 t.Fatalf("NewFilePreferenceStorage failed: %v", err)
22 }
23
24 if storage == nil {
25 t.Fatal("storage should not be nil")
26 }
27
28 // 验证目录是否创建
29 if _, err := os.Stat(tmpDir); os.IsNotExist(err) {
30 t.Error("storage directory should be created")
31 }
32}
33
34func TestFilePreferenceStorage_Save(t *testing.T) {
35 tmpDir := filepath.Join(os.TempDir(), "test-preferences-save")

Callers

nothing calls this directly

Calls 4

NewFilePreferenceStorageFunction · 0.85
StatMethod · 0.65
ErrorMethod · 0.65
JoinMethod · 0.45

Tested by

no test coverage detected