summaryrefslogtreecommitdiff
path: root/cache/cache_test.go
diff options
context:
space:
mode:
authorewy <ewy0@protonmail.com>2026-05-16 23:14:48 +0200
committerewy <ewy0@protonmail.com>2026-05-16 23:14:48 +0200
commit7984fd9beaa7c903288142818cb328c584a139a5 (patch)
tree204e65d7eef2db75b13d3140c744f542f40b3f01 /cache/cache_test.go
parentfc9f25805f85cf9b371f60572ced8647a1eef8e0 (diff)
add tests for nil caches
Diffstat (limited to 'cache/cache_test.go')
-rw-r--r--cache/cache_test.go27
1 files changed, 24 insertions, 3 deletions
diff --git a/cache/cache_test.go b/cache/cache_test.go
index 5f6a501..8753ad6 100644
--- a/cache/cache_test.go
+++ b/cache/cache_test.go
@@ -3,12 +3,13 @@
package cache
import (
- . "github.com/ewy1/pik/runner"
- "github.com/stretchr/testify/assert"
"path/filepath"
"strings"
"testing"
"testing/fstest"
+
+ . "github.com/ewy1/pik/runner"
+ "github.com/stretchr/testify/assert"
)
func TestLoadFile(t *testing.T) {
@@ -34,7 +35,7 @@ func TestLoadFile(t *testing.T) {
}
func TestFromReader_Blank(t *testing.T) {
- input := `
+ input := `
`
sr := strings.NewReader(input)
c, err := Unmarshal(sr)
@@ -183,3 +184,23 @@ func TestSaveFile(t *testing.T) {
err := SaveFile(loc, c)
assert.NoError(t, err)
}
+
+func TestMergeEmptyNil(t *testing.T) {
+ empty := &Cache{}
+ empty.Merge(nil)
+}
+
+func TestMergeNormalNil(t *testing.T) {
+ c := &Cache{
+ Entries: []Entry{{Path: "123", Label: "/asdf"}},
+ }
+ c.Merge(nil)
+}
+
+func TestMergeNilNormal(t *testing.T) {
+ var e *Cache = nil
+ c := &Cache{
+ Entries: []Entry{{Path: "123", Label: "/asdf"}},
+ }
+ _ = e.Merge(c)
+}