Skip to content
This repository has been archived by the owner on Apr 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #77 from mercari/worker_test
Browse files Browse the repository at this point in the history
test: Add test code for worker
  • Loading branch information
cubicdaiya authored Sep 29, 2017
2 parents 91eda29 + ae8459a commit 1bf6d93
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions gaurun/worker_test.go
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)
}
}

0 comments on commit 1bf6d93

Please sign in to comment.