This repository has been archived by the owner on Apr 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #77 from mercari/worker_test
test: Add test code for worker
- Loading branch information
Showing
1 changed file
with
35 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package gaurun | ||
|
||
import ( | ||
"errors" | ||
"testing" | ||
|
||
"github.com/RobotsAndPencils/buford/push" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestIsExternalServerError(t *testing.T) { | ||
cases := []struct { | ||
Err error | ||
Platform int | ||
Expected bool | ||
}{ | ||
{push.ErrIdleTimeout, PlatFormIos, true}, | ||
{push.ErrShutdown, PlatFormIos, true}, | ||
{push.ErrInternalServerError, PlatFormIos, true}, | ||
{push.ErrServiceUnavailable, PlatFormIos, true}, | ||
{errors.New("no error"), PlatFormIos, false}, | ||
|
||
{errors.New("Unavailable"), PlatFormAndroid, true}, | ||
{errors.New("InternalServerError"), PlatFormAndroid, true}, | ||
{errors.New("Timeout"), PlatFormAndroid, true}, | ||
{errors.New("no error"), PlatFormAndroid, false}, | ||
|
||
{errors.New("no error"), 100 /* neither iOS nor Android */, false}, | ||
} | ||
|
||
for _, c := range cases { | ||
actual := isExternalServerError(c.Err, c.Platform) | ||
assert.Equal(t, actual, c.Expected) | ||
} | ||
} |