summaryrefslogtreecommitdiff
path: root/cache/cache_test.go
diff options
context:
space:
mode:
authorewy <ewy0@protonmail.com>2026-04-22 20:44:06 +0200
committerewy <ewy0@protonmail.com>2026-04-22 20:44:06 +0200
commit086a0cc0eb75c0c3a15cf6a715427df1e2d589a2 (patch)
tree0bcc881b202f94a7ea39f94f13aea89ca2046312 /cache/cache_test.go
parentc6a362a039b1662dfc0badeb8badc4458e446787 (diff)
slowly working on that test coverage
Diffstat (limited to 'cache/cache_test.go')
-rw-r--r--cache/cache_test.go29
1 files changed, 24 insertions, 5 deletions
diff --git a/cache/cache_test.go b/cache/cache_test.go
index 38c100a..1a9c46d 100644
--- a/cache/cache_test.go
+++ b/cache/cache_test.go
@@ -4,6 +4,7 @@ package cache
import (
"github.com/stretchr/testify/assert"
+ "path/filepath"
. "pik/testx"
"strings"
"testing"
@@ -36,7 +37,7 @@ func TestFromReader_Blank(t *testing.T) {
input := `
`
sr := strings.NewReader(input)
- c, err := Load(sr)
+ c, err := Unmarshal(sr)
assert.Nil(t, err)
assert.Len(t, c.Entries, 0)
}
@@ -44,7 +45,7 @@ func TestFromReader_Blank(t *testing.T) {
func TestFromReader_OneEntry(t *testing.T) {
input := `/abc/def # deffers`
sr := strings.NewReader(input)
- c, err := Load(sr)
+ c, err := Unmarshal(sr)
assert.Nil(t, err)
assert.Len(t, c.Entries, 1)
assert.Equal(t, c.Entries[0], Entry{
@@ -59,7 +60,7 @@ func TestFromReader_ManyEntries(t *testing.T) {
/path/src # da source
`
sr := strings.NewReader(input)
- c, err := Load(sr)
+ c, err := Unmarshal(sr)
assert.Nil(t, err)
assert.Len(t, c.Entries, 3)
assert.Equal(t, c.Entries[0], Entry{
@@ -87,7 +88,7 @@ func TestFromReader_Comments(t *testing.T) {
# // comment
`
sr := strings.NewReader(input)
- c, err := Load(sr)
+ c, err := Unmarshal(sr)
assert.Nil(t, err)
assert.Len(t, c.Entries, 3)
assert.Equal(t, c.Entries[0], Entry{
@@ -162,6 +163,24 @@ func TestLoadFile_NotExist(t *testing.T) {
f := fstest.MapFS{}
c, err := LoadFile(f, "anything is fine")
assert.Nil(t, c.Entries)
- assert.Error(t, err)
+ assert.NoError(t, err)
+
+}
+func TestSaveFile(t *testing.T) {
+ dir := t.TempDir()
+ loc := filepath.Join(dir, "savefile")
+ st := TState(TSource("source_one", "target"), TSource("second_source", "t1", "t2", "t3"))
+ c := Cache{Entries: []Entry{
+ {
+ Path: "path",
+ Label: "label",
+ },
+ {
+ Path: "/otherpath/123",
+ Label: "",
+ },
+ }}
+ err := SaveFile(loc, st, c)
+ assert.NoError(t, err)
}