MCPcopy
hub / github.com/cli/cli / TestClearCacheRun

Function TestClearCacheRun

pkg/cmd/config/clear-cache/clear_cache_test.go:13–32  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

11)
12
13func TestClearCacheRun(t *testing.T) {
14 cacheDir := filepath.Join(t.TempDir(), "gh-cli-cache")
15 ios, _, stdout, stderr := iostreams.Test()
16 opts := &ClearCacheOptions{
17 IO: ios,
18 CacheDir: cacheDir,
19 }
20
21 if err := os.Mkdir(opts.CacheDir, 0600); err != nil {
22 assert.NoError(t, err)
23 }
24
25 if err := clearCacheRun(opts); err != nil {
26 assert.NoError(t, err)
27 }
28
29 assert.NoDirExistsf(t, opts.CacheDir, fmt.Sprintf("Cache dir: %s still exists", opts.CacheDir))
30 assert.Equal(t, "✓ Cleared the cache\n", stdout.String())
31 assert.Equal(t, "", stderr.String())
32}

Callers

nothing calls this directly

Calls 5

TestFunction · 0.92
clearCacheRunFunction · 0.85
JoinMethod · 0.80
EqualMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected