Skip to content

Instantly share code, notes, and snippets.

@caalberts
Created December 27, 2017 15:09
Show Gist options
  • Save caalberts/272ce0d7680fff0861af430baa7f9617 to your computer and use it in GitHub Desktop.
Save caalberts/272ce0d7680fff0861af430baa7f9617 to your computer and use it in GitHub Desktop.
func TestFetchAccountWhenAccountExists(t *testing.T) {
repository := createRepositoryWithData(fakeData)
account, err := repository.FetchAccount(id)
assert.Equal(t, id, account.Id)
assert.Equal(t, "John Doe", account.Name)
assert.Equal(t, 100, account.Balance)
assert.Nil(t, err)
}
func createRepositoryWithData(fakeData map[string]string) *AccountRepository {
redis := stubRedis{data: fakeData}
repository := NewAccountRepository(&redis)
return repository
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment