MCPcopy
hub / github.com/etcd-io/etcd / TestExist

Function TestExist

client/pkg/fileutil/fileutil_test.go:59–80  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

57}
58
59func TestExist(t *testing.T) {
60 fdir := filepath.Join(os.TempDir(), fmt.Sprint(time.Now().UnixNano()+rand.Int63n(1000)))
61 os.RemoveAll(fdir)
62 if err := os.Mkdir(fdir, 0o666); err != nil {
63 t.Skip(err)
64 }
65 defer os.RemoveAll(fdir)
66 require.Truef(t, Exist(fdir), "expected Exist true, got %v", Exist(fdir))
67
68 f, err := os.CreateTemp(os.TempDir(), "fileutil")
69 require.NoError(t, err)
70 f.Close()
71
72 if g := Exist(f.Name()); !g {
73 t.Errorf("exist = %v, want true", g)
74 }
75
76 os.Remove(f.Name())
77 if g := Exist(f.Name()); g {
78 t.Errorf("exist = %v, want false", g)
79 }
80}
81
82func TestDirEmpty(t *testing.T) {
83 dir := t.TempDir()

Callers

nothing calls this directly

Calls 7

ExistFunction · 0.70
TempDirMethod · 0.65
SkipMethod · 0.65
CloseMethod · 0.65
NameMethod · 0.65
ErrorfMethod · 0.65
RemoveMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…