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

Function TestAllocCollection

collection_test.go:1175–1250  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1173}
1174
1175func TestAllocCollection(t *testing.T) {
1176 m, err := NewCollection(CollectionOptions{})
1177 if err != nil || m == nil {
1178 t.Errorf("expected moss")
1179 }
1180
1181 err = m.Start()
1182 if err != nil {
1183 t.Errorf("expected Start ok")
1184 }
1185
1186 b, err := m.NewBatch(4, 5)
1187 if err != nil {
1188 t.Errorf("expected NewBatch with preallocs ok")
1189 }
1190
1191 a, err := b.Alloc(100)
1192 if err == nil || a != nil {
1193 t.Errorf("expected over-Alloc() to fail")
1194 }
1195
1196 a, err = b.Alloc(2)
1197 if err != nil || len(a) != 2 {
1198 t.Errorf("expected Alloc to work")
1199 }
1200 a[0] = 'a'
1201 a[1] = 'A'
1202
1203 err = b.AllocSet(a[0:1], a[1:2])
1204 if err != nil {
1205 t.Errorf("expected AllocSet to work")
1206 }
1207
1208 a, err = b.Alloc(1)
1209 if err != nil || len(a) != 1 {
1210 t.Errorf("expected Alloc to work")
1211 }
1212 a[0] = 'b'
1213
1214 err = b.AllocSet(a[0:1], nil)
1215 if err != nil {
1216 t.Errorf("expected AllocSet to work")
1217 }
1218
1219 a, err = b.Alloc(1)
1220 if err != nil || len(a) != 1 {
1221 t.Errorf("expected Alloc to work")
1222 }
1223 a[0] = 'c'
1224
1225 err = b.AllocDel(a[0:1])
1226 if err != nil {
1227 t.Errorf("expected AllocDel to work")
1228 }
1229
1230 a, err = b.Alloc(1)
1231 if err != nil || len(a) != 1 {
1232 t.Errorf("expected Alloc to work")

Callers

nothing calls this directly

Calls 9

StartMethod · 0.95
NewBatchMethod · 0.95
AllocMethod · 0.95
AllocSetMethod · 0.95
AllocDelMethod · 0.95
AllocMergeMethod · 0.95
ExecuteBatchMethod · 0.95
CloseMethod · 0.95
NewCollectionFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…