Files
notarius/internal/core/config/cache_test.go

22 lines
561 B
Go
Raw Normal View History

package config
import (
"errors"
"path/filepath"
"testing"
)
func TestDefaultCacheRootUsesOneApplicationDirectory(t *testing.T) {
root, err := DefaultCacheRoot(func() (string, error) { return "/tmp/user-cache", nil })
if err != nil {
t.Fatal(err)
}
if root != filepath.Join("/tmp/user-cache", "notarius") {
t.Fatalf("root = %q", root)
}
failure := errors.New("cache home unavailable")
if _, err := DefaultCacheRoot(func() (string, error) { return "", failure }); !errors.Is(err, failure) {
t.Fatalf("lost cache discovery error: %v", err)
}
}