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) } }