MCPcopy Create free account
hub / github.com/couchbase/moss / TestOpenEmptyStore

Function TestOpenEmptyStore

store_test.go:108–185  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

106}
107
108func TestOpenEmptyStore(t *testing.T) {
109 tmpDir, _ := ioutil.TempDir("", "mossStore")
110 defer os.RemoveAll(tmpDir)
111
112 s, err := OpenStore(tmpDir, StoreOptions{})
113 if err != nil {
114 t.Errorf("expected open empty store to work")
115 }
116
117 if s.Dir() != tmpDir {
118 t.Errorf("expected same dir")
119 }
120
121 s.Options() // It should not panic.
122
123 sstats, err := s.Stats()
124 if err != nil {
125 t.Errorf("expected no stats err")
126 }
127 if sstats == nil {
128 t.Errorf("expected non-nil stats")
129 }
130 if sstats["num_bytes_used_disk"].(uint64) != 0 {
131 t.Errorf("expected 0 stats to start")
132 }
133 if sstats["total_persists"].(uint64) != 0 {
134 t.Errorf("expected 0 stats to start")
135 }
136 if sstats["total_compactions"].(uint64) != 0 {
137 t.Errorf("expected 0 stats to start")
138 }
139
140 ss, err := s.Snapshot()
141 if err != nil || ss == nil {
142 t.Errorf("expected snapshot, no err")
143 }
144 ss2, err := s.Persist(ss, StorePersistOptions{})
145 if err == nil || ss2 != nil {
146 t.Errorf("expected persist of non-segmentStack to err")
147 }
148
149 v, err := ss.Get([]byte("a"), ReadOptions{})
150 if err != nil || v != nil {
151 t.Errorf("expected no a")
152 }
153
154 iter, err := ss.StartIterator(nil, nil, IteratorOptions{})
155 if err != nil || iter == nil {
156 t.Errorf("expected ss iter to start")
157 }
158 err = iter.Next()
159 if err != ErrIteratorDone {
160 t.Errorf("expected done")
161 }
162 k, v, err := iter.Current()
163 if err != ErrIteratorDone || k != nil || v != nil {
164 t.Errorf("expected done")
165 }

Callers

nothing calls this directly

Calls 11

OpenStoreFunction · 0.85
DirMethod · 0.80
OptionsMethod · 0.65
StatsMethod · 0.65
SnapshotMethod · 0.65
PersistMethod · 0.65
GetMethod · 0.65
StartIteratorMethod · 0.65
NextMethod · 0.65
CurrentMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…