MCPcopy Index your code
hub / github.com/git-bug/git-bug / RepoStorageTest

Function RepoStorageTest

repository/repo_testing.go:54–82  ·  view source on GitHub ↗
(t *testing.T, repo RepoStorage)

Source from the content-addressed store, hash-verified

52}
53
54func RepoStorageTest(t *testing.T, repo RepoStorage) {
55 storage := repo.LocalStorage()
56
57 err := storage.MkdirAll("foo/bar", 0755)
58 require.NoError(t, err)
59
60 f, err := storage.Create("foo/bar/foofoo")
61 require.NoError(t, err)
62
63 _, err = f.Write([]byte("hello"))
64 require.NoError(t, err)
65
66 err = f.Close()
67 require.NoError(t, err)
68
69 // remove all
70 err = storage.RemoveAll(".")
71 require.NoError(t, err)
72
73 fi, err := storage.ReadDir(".")
74 // a real FS would remove the root directory with RemoveAll and subsequent call would fail
75 // a memory FS would still have a virtual root and subsequent call would succeed
76 // not ideal, but will do for now
77 if err == nil {
78 require.Empty(t, fi)
79 } else {
80 require.True(t, os.IsNotExist(err))
81 }
82}
83
84func randomHash() Hash {
85 var letterRunes = "abcdef0123456789"

Callers 1

RepoTestFunction · 0.85

Calls 4

LocalStorageMethod · 0.65
CloseMethod · 0.65
RemoveAllMethod · 0.65
WriteMethod · 0.45

Tested by

no test coverage detected