summaryrefslogtreecommitdiffstats
path: root/vendor/gopkg.in/olivere/elastic.v5/errors_test.go
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2017-07-20 15:22:49 -0700
committerGitHub <noreply@github.com>2017-07-20 15:22:49 -0700
commit58839cefb50e56ae5b157b37e9814ae83ceee70b (patch)
tree5de966481678096fc9567f74f96673b34a65127c /vendor/gopkg.in/olivere/elastic.v5/errors_test.go
parente2f4492eadb5d3c58606b1fdd5774b63a07c236a (diff)
downloadchat-58839cefb50e56ae5b157b37e9814ae83ceee70b.tar.gz
chat-58839cefb50e56ae5b157b37e9814ae83ceee70b.tar.bz2
chat-58839cefb50e56ae5b157b37e9814ae83ceee70b.zip
Upgrading server dependancies (#6984)
Diffstat (limited to 'vendor/gopkg.in/olivere/elastic.v5/errors_test.go')
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/errors_test.go93
1 files changed, 93 insertions, 0 deletions
diff --git a/vendor/gopkg.in/olivere/elastic.v5/errors_test.go b/vendor/gopkg.in/olivere/elastic.v5/errors_test.go
index c33dc2d6d..75d3949e5 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/errors_test.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/errors_test.go
@@ -200,3 +200,96 @@ func TestIsTimeout(t *testing.T) {
t.Errorf("expected %v; got: %v", want, got)
}
}
+
+func TestIsConflict(t *testing.T) {
+ if got, want := IsConflict(nil), false; got != want {
+ t.Errorf("expected %v; got: %v", want, got)
+ }
+ if got, want := IsConflict(""), false; got != want {
+ t.Errorf("expected %v; got: %v", want, got)
+ }
+ if got, want := IsConflict(200), false; got != want {
+ t.Errorf("expected %v; got: %v", want, got)
+ }
+ if got, want := IsConflict(http.StatusConflict), true; got != want {
+ t.Errorf("expected %v; got: %v", want, got)
+ }
+
+ if got, want := IsConflict(&Error{Status: 409}), true; got != want {
+ t.Errorf("expected %v; got: %v", want, got)
+ }
+ if got, want := IsConflict(&Error{Status: 200}), false; got != want {
+ t.Errorf("expected %v; got: %v", want, got)
+ }
+
+ if got, want := IsConflict(Error{Status: 409}), true; got != want {
+ t.Errorf("expected %v; got: %v", want, got)
+ }
+ if got, want := IsConflict(Error{Status: 200}), false; got != want {
+ t.Errorf("expected %v; got: %v", want, got)
+ }
+
+ if got, want := IsConflict(&http.Response{StatusCode: 409}), true; got != want {
+ t.Errorf("expected %v; got: %v", want, got)
+ }
+ if got, want := IsConflict(&http.Response{StatusCode: 200}), false; got != want {
+ t.Errorf("expected %v; got: %v", want, got)
+ }
+}
+
+func TestIsStatusCode(t *testing.T) {
+ tests := []struct {
+ Error interface{}
+ Code int
+ Want bool
+ }{
+ // #0
+ {
+ Error: nil,
+ Code: 200,
+ Want: false,
+ },
+ // #1
+ {
+ Error: "",
+ Code: 200,
+ Want: false,
+ },
+ // #2
+ {
+ Error: http.StatusConflict,
+ Code: 409,
+ Want: true,
+ },
+ // #3
+ {
+ Error: http.StatusConflict,
+ Code: http.StatusInternalServerError,
+ Want: false,
+ },
+ // #4
+ {
+ Error: &Error{Status: http.StatusConflict},
+ Code: 409,
+ Want: true,
+ },
+ // #5
+ {
+ Error: Error{Status: http.StatusConflict},
+ Code: 409,
+ Want: true,
+ },
+ // #6
+ {
+ Error: &http.Response{StatusCode: http.StatusConflict},
+ Code: 409,
+ Want: true,
+ },
+ }
+
+ for i, tt := range tests {
+ if have, want := IsStatusCode(tt.Error, tt.Code), tt.Want; have != want {
+ t.Errorf("#%d: have %v, want %v", i, have, want)
+ }
+ }
+}