-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcache_test.go
More file actions
37 lines (32 loc) · 879 Bytes
/
Copy pathcache_test.go
File metadata and controls
37 lines (32 loc) · 879 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
36
37
package contexting
import (
"path/filepath"
"testing"
)
func TestLoadAndSaveSynonymCache(t *testing.T) {
tmpDir := t.TempDir()
path := filepath.Join(tmpDir, "synonyms_cache.json")
initial, err := LoadSynonymCache(path)
if err != nil {
t.Fatalf("load empty cache: %v", err)
}
if len(initial) != 0 {
t.Fatalf("expected empty cache for missing file, got %v", initial)
}
cache := SynonymResponse{"config": {"settings", "file", "state"}}
if err := SaveSynonymCache(path, cache); err != nil {
t.Fatalf("save cache: %v", err)
}
loaded, err := LoadSynonymCache(path)
if err != nil {
t.Fatalf("load cache: %v", err)
}
if len(loaded["config"]) == 0 {
t.Fatalf("expected config synonyms in loaded cache")
}
for _, syn := range loaded["config"] {
if syn == "file" {
t.Fatalf("expected generic synonym to be filtered, got %v", loaded["config"])
}
}
}