Skip to content

Commit

Permalink
testing: refactor fetch tests to make satisfy the linter
Browse files Browse the repository at this point in the history
  • Loading branch information
aschmahmann committed Dec 2, 2019
1 parent 518d15c commit 45be97b
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions fetch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ func TestFetchProtocolTrip(t *testing.T) {
d2 := &datastore{map[string][]byte{"key": []byte("value2")}}
h2 := newFetchProtocol(ctx, hosts[1], d2.Lookup)

fetchCheck(t, ctx, h1, h2, "key", []byte("value2"))
fetchCheck(t, ctx, h2, h1, "key", []byte("value1"))
fetchCheck(ctx, t, h1, h2, "key", []byte("value2"))
fetchCheck(ctx, t, h2, h1, "key", []byte("value1"))
}

func TestFetchProtocolNotFound(t *testing.T) {
Expand All @@ -66,8 +66,8 @@ func TestFetchProtocolNotFound(t *testing.T) {
d2 := &datastore{make(map[string][]byte)}
h2 := newFetchProtocol(ctx, hosts[1], d2.Lookup)

fetchCheck(t, ctx, h1, h2, "key", nil)
fetchCheck(t, ctx, h2, h1, "key", []byte("value1"))
fetchCheck(ctx, t, h1, h2, "key", nil)
fetchCheck(ctx, t, h2, h1, "key", []byte("value1"))
}

func TestFetchProtocolRepeated(t *testing.T) {
Expand All @@ -87,12 +87,12 @@ func TestFetchProtocolRepeated(t *testing.T) {
h2 := newFetchProtocol(ctx, hosts[1], d2.Lookup)

for i := 0; i < 10; i++ {
fetchCheck(t, ctx, h1, h2, "key", nil)
fetchCheck(t, ctx, h2, h1, "key", []byte("value1"))
fetchCheck(ctx, t, h1, h2, "key", nil)
fetchCheck(ctx, t, h2, h1, "key", []byte("value1"))
}
}

func fetchCheck(t *testing.T, ctx context.Context,
func fetchCheck(ctx context.Context, t *testing.T,
requester *fetchProtocol, responder *fetchProtocol, key string, expected []byte) {
data, err := requester.Fetch(ctx, responder.host.ID(), key)
if err != nil {
Expand Down

0 comments on commit 45be97b

Please sign in to comment.