TestStatusString tests Status.String method
(t *testing.T)
| 12 | |
| 13 | // TestStatusString tests Status.String method |
| 14 | func TestStatusString(t *testing.T) { |
| 15 | type testData struct { |
| 16 | status Status // Input Op code |
| 17 | s string // Expected output string |
| 18 | } |
| 19 | |
| 20 | tests := []testData{ |
| 21 | {StatusOk, "successful-ok"}, |
| 22 | {StatusOkConflicting, "successful-ok-conflicting-attributes"}, |
| 23 | {StatusOkEventsComplete, "successful-ok-events-complete"}, |
| 24 | {StatusRedirectionOtherSite, "redirection-other-site"}, |
| 25 | {StatusErrorBadRequest, "client-error-bad-request"}, |
| 26 | {StatusErrorForbidden, "client-error-forbidden"}, |
| 27 | {StatusErrorNotFetchable, "client-error-not-fetchable"}, |
| 28 | {StatusErrorInternal, "server-error-internal-error"}, |
| 29 | {StatusErrorTooManyDocuments, "server-error-too-many-documents"}, |
| 30 | {0xabcd, "0xabcd"}, |
| 31 | } |
| 32 | |
| 33 | for _, test := range tests { |
| 34 | s := test.status.String() |
| 35 | if s != test.s { |
| 36 | t.Errorf("testing Status.String:\n"+ |
| 37 | "input: 0x%4.4x\n"+ |
| 38 | "expected: %s\n"+ |
| 39 | "present: %s\n", |
| 40 | int(test.status), test.s, s, |
| 41 | ) |
| 42 | } |
| 43 | } |
| 44 | } |