Skip to content

Instantly share code, notes, and snippets.

@madflojo
Created February 14, 2021 18:41
Show Gist options
  • Save madflojo/253529b11a5ab8aaf212286640b30723 to your computer and use it in GitHub Desktop.
Save madflojo/253529b11a5ab8aaf212286640b30723 to your computer and use it in GitHub Desktop.
Interface Article - MockDB Implementation
type MockDB struct {
// FakeFetch is used to provide unique test case results
FakeFetch func(string) (int, error)
}
func (m *MockDB) Fetch(k string) (int, error) {
if m.FakeFetch != nil {
return m.FakeFetch(k)
}
return 0, nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment