MCPcopy Create free account
hub / github.com/celer-pkg/celer / TestCCache_Setup_RemoteStorage

Function TestCCache_Setup_RemoteStorage

configs/ccache_test.go:54–90  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

52}
53
54func TestCCache_Setup_RemoteStorage(t *testing.T) {
55 keys := []string{"CCACHE_REMOTE_STORAGE", "CCACHE_REMOTE_ONLY"}
56 saved := make(map[string]string)
57 for _, key := range keys {
58 v, _ := os.LookupEnv(key)
59 saved[key] = v
60 }
61 defer func() {
62 for k, v := range saved {
63 if v != "" {
64 os.Setenv(k, v)
65 } else {
66 os.Unsetenv(k)
67 }
68 }
69 }()
70
71 dir := t.TempDir()
72 ccahce := &CCache{
73 Enabled: true,
74 Dir: dir,
75 MaxSize: "1G",
76 RemoteStorage: "file:///tmp/ccache-remote",
77 RemoteOnly: true,
78 }
79
80 if err := ccahce.Setup(); err != nil {
81 t.Fatalf("Setup() error = %v", err)
82 }
83
84 if v := os.Getenv("CCACHE_REMOTE_STORAGE"); v != ccahce.RemoteStorage {
85 t.Errorf("CCACHE_REMOTE_STORAGE = %q, want %q", v, ccahce.RemoteStorage)
86 }
87 if v := os.Getenv("CCACHE_REMOTE_ONLY"); v != "1" {
88 t.Errorf("CCACHE_REMOTE_ONLY = %q, want 1", v)
89 }
90}
91
92func TestCCache_Setup_MkdirFails(t *testing.T) {
93 // Use a path that cannot be created: parent is a file, not a directory.

Callers

nothing calls this directly

Calls 1

SetupMethod · 0.95

Tested by

no test coverage detected