-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'andy/feature--track-nil-results'
- Loading branch information
Showing
12 changed files
with
403 additions
and
94 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 |
---|---|---|
|
@@ -20,3 +20,4 @@ | |
|
||
|
||
vendor/ | ||
todo.txt |
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
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,10 @@ | ||
module github.com/andy9775/dataloader | ||
|
||
require ( | ||
github.com/bouk/monkey v1.0.0 | ||
github.com/davecgh/go-spew v1.1.0 | ||
github.com/opentracing/opentracing-go v1.0.2 | ||
github.com/pmezard/go-difflib v1.0.0 | ||
github.com/stretchr/testify v1.2.2 | ||
golang.org/x/net v0.0.0-20180808004115-f9ce57c11b24 | ||
) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package dataloader_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/andy9775/dataloader" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
// ================================================== tests ================================================== | ||
// TestEnsureOKForResult tests getting the result value with a valid key expecting a valid value | ||
func TestEnsureOKForResult(t *testing.T) { | ||
// setup | ||
rmap := dataloader.NewResultMap(2) | ||
key := PrimaryKey(1) | ||
value := dataloader.Result{Result: 1, Err: nil} | ||
rmap.Set(key.String(), value) | ||
|
||
// invoke/assert | ||
result, ok := rmap.GetValue(key) | ||
assert.True(t, ok, "Expected valid result to have been found") | ||
assert.Equal(t, result, value, "Expected result") | ||
} | ||
func TestEnsureNotOKForResult(t *testing.T) { | ||
// setup | ||
rmap := dataloader.NewResultMap(2) | ||
key := PrimaryKey(1) | ||
key2 := PrimaryKey(2) | ||
value := dataloader.Result{Result: 1, Err: nil} | ||
rmap.Set(key.String(), value) | ||
|
||
// invoke/assert | ||
result, ok := rmap.GetValue(key2) | ||
assert.False(t, ok, "Expected valid result to have been found") | ||
assert.Nil(t, result.Result, "Expected nil result") | ||
} |
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
Oops, something went wrong.