Skip to content

Commit 0ee8b60

Browse files
committed
Respond to breaking interface changes (#justprev1thingzzz)
1 parent c9da7d1 commit 0ee8b60

File tree

4 files changed

+16
-14
lines changed

4 files changed

+16
-14
lines changed

bitcask/bitcask.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ func (db *DB) Destroy(storeName string) error {
325325
}
326326

327327
// With calls the given underlying bitcask instance.
328-
func (db *DB) With(storeName string) database.Store {
328+
func (db *DB) With(storeName string) database.Filer {
329329
if err := db.init(); err != nil {
330330
panic(err)
331331
}

bitcask/bitcask_search_test.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
c "git.tcp.direct/kayos/common/entropy"
1111
"github.com/davecgh/go-spew/spew"
1212

13+
"git.tcp.direct/tcp.direct/database"
1314
"git.tcp.direct/tcp.direct/database/kv"
1415
)
1516

@@ -111,7 +112,7 @@ func Test_Search(t *testing.T) {
111112
db.store["yeet"] = &Store{Bitcask: nil}
112113
t.Run("BasicSearch", func(t *testing.T) {
113114
t.Logf("executing search for %s", needle)
114-
resChan, errChan := db.With(storename).Search(needle)
115+
resChan, errChan := db.With(storename).(database.Store).Search(needle)
115116
var keys = []int{one, two, three, four, five}
116117
var needed = len(keys)
117118

@@ -146,7 +147,7 @@ func Test_Search(t *testing.T) {
146147
bogus := c.RandStr(55)
147148
t.Logf("executing search for %s", bogus)
148149
var results []kv.KeyValue
149-
resChan, errChan := db.With(storename).Search(bogus)
150+
resChan, errChan := db.With(storename).(database.Store).Search(bogus)
150151
select {
151152
case err := <-errChan:
152153
t.Errorf("failed to search: %s", err.Error())
@@ -170,7 +171,7 @@ func Test_ValueExists(t *testing.T) {
170171
needles := addJunk(db, storename, c.RNG(100), c.RNG(100), c.RNG(100), c.RNG(100), c.RNG(100), t, true)
171172

172173
for _, ndl := range needles {
173-
k, exists := db.With(storename).ValueExists(ndl)
174+
k, exists := db.With(storename).(database.Store).ValueExists(ndl)
174175
if !exists {
175176
t.Fatalf("[FAIL] store should have contained a value %s somewhere, it did not.", string(ndl))
176177
}
@@ -189,7 +190,7 @@ func Test_ValueExists(t *testing.T) {
189190
t.Run("ValueShouldNotExist", func(t *testing.T) {
190191
for n := 0; n != 5; n++ {
191192
garbage := c.RandStr(55)
192-
if _, exists := db.With(storename).ValueExists([]byte(garbage)); exists {
193+
if _, exists := db.With(storename).(database.Store).ValueExists([]byte(garbage)); exists {
193194
t.Errorf("[FAIL] store should have not contained value %v, but it did", []byte(garbage))
194195
} else {
195196
t.Logf("[SUCCESS] store succeeded in not having random value %s", garbage)
@@ -200,7 +201,7 @@ func Test_ValueExists(t *testing.T) {
200201
t.Run("ValueExistNilBitcask", func(t *testing.T) {
201202
db.store["asdb"] = &Store{Bitcask: nil}
202203
garbage := "yeet"
203-
if _, exists := db.With(storename).ValueExists([]byte(garbage)); exists {
204+
if _, exists := db.With(storename).(database.Store).ValueExists([]byte(garbage)); exists {
204205
t.Errorf("[FAIL] store should have not contained value %v, should have been nil", []byte(garbage))
205206
} else {
206207
t.Log("[SUCCESS] store succeeded in being nil")
@@ -227,7 +228,7 @@ func Test_PrefixScan(t *testing.T) {
227228
t.Logf("added needle with key(value): %s(%s)", combo.Key.String(), combo.Value.String())
228229
}
229230
}
230-
resChan, errChan := db.With(storename).PrefixScan("user:")
231+
resChan, errChan := db.With(storename).(database.Store).PrefixScan("user:")
231232
var results []kv.KeyValue
232233
for keyValue := range resChan {
233234
results = append(results, keyValue)

pogreb/pogreb.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ func (db *DB) Init(storeName string, opts ...any) error {
346346
}
347347

348348
// With calls the given underlying pogreb instance.
349-
func (db *DB) With(storeName string) database.Store {
349+
func (db *DB) With(storeName string) database.Filer {
350350
if err := db.init(); err != nil {
351351
panic(err)
352352
}

pogreb/pogreb_search_test.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
c "git.tcp.direct/kayos/common/entropy"
1111
"github.com/davecgh/go-spew/spew"
1212

13+
"git.tcp.direct/tcp.direct/database"
1314
"git.tcp.direct/tcp.direct/database/kv"
1415
)
1516

@@ -111,7 +112,7 @@ func Test_Search(t *testing.T) {
111112
db.store["yeet"] = &Store{DB: nil}
112113
t.Run("BasicSearch", func(t *testing.T) {
113114
t.Logf("executing search for %s", needle)
114-
resChan, errChan := db.With(storename).Search(needle)
115+
resChan, errChan := db.With(storename).(database.Store).Search(needle)
115116
var keys = []int{one, two, three, four, five}
116117
var needed = len(keys)
117118

@@ -146,7 +147,7 @@ func Test_Search(t *testing.T) {
146147
bogus := c.RandStr(55)
147148
t.Logf("executing search for %s", bogus)
148149
var results []kv.KeyValue
149-
resChan, errChan := db.With(storename).Search(bogus)
150+
resChan, errChan := db.With(storename).(database.Store).Search(bogus)
150151
select {
151152
case err := <-errChan:
152153
t.Errorf("failed to search: %s", err.Error())
@@ -170,7 +171,7 @@ func Test_ValueExists(t *testing.T) {
170171
needles := addJunk(db, storename, c.RNG(100), c.RNG(100), c.RNG(100), c.RNG(100), c.RNG(100), t, true)
171172

172173
for _, ndl := range needles {
173-
k, exists := db.With(storename).ValueExists(ndl)
174+
k, exists := db.With(storename).(database.Store).ValueExists(ndl)
174175
if !exists {
175176
t.Fatalf("[FAIL] store should have contained a value %s somewhere, it did not.", string(ndl))
176177
}
@@ -189,7 +190,7 @@ func Test_ValueExists(t *testing.T) {
189190
t.Run("ValueShouldNotExist", func(t *testing.T) {
190191
for n := 0; n != 5; n++ {
191192
garbage := c.RandStr(55)
192-
if _, exists := db.With(storename).ValueExists([]byte(garbage)); exists {
193+
if _, exists := db.With(storename).(database.Store).ValueExists([]byte(garbage)); exists {
193194
t.Errorf("[FAIL] store should have not contained value %v, but it did", []byte(garbage))
194195
} else {
195196
t.Logf("[SUCCESS] store succeeded in not having random value %s", garbage)
@@ -200,7 +201,7 @@ func Test_ValueExists(t *testing.T) {
200201
t.Run("ValueExistNilBitcask", func(t *testing.T) {
201202
db.store["asdb"] = &Store{DB: nil}
202203
garbage := "yeet"
203-
if _, exists := db.With(storename).ValueExists([]byte(garbage)); exists {
204+
if _, exists := db.With(storename).(database.Store).ValueExists([]byte(garbage)); exists {
204205
t.Errorf("[FAIL] store should have not contained value %v, should have been nil", []byte(garbage))
205206
} else {
206207
t.Log("[SUCCESS] store succeeded in being nil")
@@ -227,7 +228,7 @@ func Test_PrefixScan(t *testing.T) {
227228
t.Logf("added needle with key(value): %s(%s)", combo.Key.String(), combo.Value.String())
228229
}
229230
}
230-
resChan, errChan := db.With(storename).PrefixScan("user:")
231+
resChan, errChan := db.With(storename).(database.Store).PrefixScan("user:")
231232
var results []kv.KeyValue
232233
for keyValue := range resChan {
233234
results = append(results, keyValue)

0 commit comments

Comments
 (0)