-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fbcbd72
commit 569c3b7
Showing
3 changed files
with
87 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package store | ||
|
||
// MockIterator is a mock implementation of Iterator that simply iterates an underlying slice. | ||
type MockIterator struct { | ||
keys [][]byte | ||
values [][]byte | ||
|
||
curIndex int | ||
} | ||
|
||
func (MockIterator) Domain() ([]byte, []byte) { | ||
panic("not implemented") | ||
} | ||
|
||
func (m MockIterator) Valid() bool { | ||
return m.curIndex < len(m.keys) | ||
} | ||
|
||
func (m *MockIterator) Next() { | ||
m.curIndex++ | ||
} | ||
|
||
func (m MockIterator) Key() []byte { | ||
return m.keys[m.curIndex] | ||
} | ||
|
||
func (m MockIterator) Value() []byte { | ||
return m.values[m.curIndex] | ||
} | ||
|
||
func (m MockIterator) Error() error { | ||
panic("not implemented") | ||
} | ||
|
||
func (m MockIterator) Close() error { | ||
return nil | ||
} | ||
|
||
// NewMockIterator creates a new MockIterator. | ||
func NewMockIterator( | ||
keys [][]byte, values [][]byte, | ||
) *MockIterator { | ||
return &MockIterator{ | ||
keys: keys, | ||
values: values, | ||
curIndex: 0, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters