-
Notifications
You must be signed in to change notification settings - Fork 35
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
Showing
15 changed files
with
171 additions
and
77 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
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
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,45 @@ | ||
package redis | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/pkg/errors" | ||
) | ||
|
||
func TestIsRedisClientClosedError(t *testing.T) { | ||
tests := []struct { | ||
input error | ||
isCloseError bool | ||
}{ | ||
{ | ||
// Test exactly the error | ||
input: fmt.Errorf(redisClientClosedError), | ||
isCloseError: true, | ||
}, | ||
{ | ||
// Test the error wrapped | ||
input: errors.Wrap(fmt.Errorf(redisClientClosedError), "obfuscate"), | ||
isCloseError: true, | ||
}, | ||
{ | ||
// test not the error | ||
input: errors.New("just another error"), | ||
isCloseError: false, | ||
}, | ||
{ | ||
// test not the error wrapped with the text of the error (this should never happen) | ||
input: errors.Wrap(errors.New("just another error"), redisClientClosedError), | ||
isCloseError: false, | ||
}, | ||
} | ||
|
||
for _, test := range tests { | ||
t.Run(test.input.Error(), func(t *testing.T) { | ||
result := isRedisClientClosedError(test.input) | ||
if result != test.isCloseError { | ||
t.Fatal("failed to detect error") | ||
} | ||
}) | ||
} | ||
} |
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.