summaryrefslogtreecommitdiff
path: root/client/client_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'client/client_test.go')
-rw-r--r--client/client_test.go36
1 files changed, 1 insertions, 35 deletions
diff --git a/client/client_test.go b/client/client_test.go
index 9ccc149..b6af2b9 100644
--- a/client/client_test.go
+++ b/client/client_test.go
@@ -8,40 +8,6 @@ import (
"testing"
)
-func TestBadAuth(t *testing.T) {
- var hf http.HandlerFunc = func(w http.ResponseWriter, r *http.Request) {
- if r.Header.Get("authorization") != "token TEST-TOKEN" {
- w.WriteHeader(http.StatusUnauthorized)
- return
- }
- w.Write([]byte("encoded yay"))
- }
- tests := []struct {
- name string
- tok string
- expectErr bool
- expectBody bool
- }{
- {"valid token", "TEST-TOKEN", false, true},
- {"empty token", "", true, false},
- {"invalid token", "bad token", true, false},
- }
- server := httptest.NewServer(hf)
- defer server.Close()
- c := CaesarClient{Endpoint: server.URL}
- for _, tt := range tests {
- t.Run(tt.name, func(t *testing.T) {
- r, err := c.EncodeMessage(strings.NewReader("secret message"))
- if err == nil {
- t.Errorf("should have gotten error")
- }
- if r != nil {
- t.Errorf("should not have gotten a reader")
- }
- })
- }
-}
-
func TestEncode(t *testing.T) {
var hf http.HandlerFunc = func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("response"))
@@ -54,7 +20,7 @@ func TestEncode(t *testing.T) {
t.Errorf("should not have gotten error: %v", err)
}
if r == nil {
- t.Errorf("should have gotten a reader")
+ t.Fatalf("should have gotten a reader")
}
resp, err := ioutil.ReadAll(r)
if err != nil {