diff options
Diffstat (limited to 'server/main_test.go')
| -rw-r--r-- | server/main_test.go | 25 | 
1 files changed, 3 insertions, 22 deletions
diff --git a/server/main_test.go b/server/main_test.go index 75ddcdb..e588ae1 100644 --- a/server/main_test.go +++ b/server/main_test.go @@ -7,13 +7,12 @@ import (  	"testing"  ) -func TestHandleCaesarAllowed(t *testing.T) { -	allowAll := func(r *http.Request) bool { return true } +func TestHandleCaesar(t *testing.T) {  	bodyReader := strings.NewReader("hello world")  	req := httptest.NewRequest("POST", "/", bodyReader)  	resp := httptest.NewRecorder() -	handler := handleCaesar(allowAll) +	handler := handleCaesar()  	handler(resp, req)  	if resp.Code != http.StatusOK { @@ -26,28 +25,10 @@ func TestHandleCaesarAllowed(t *testing.T) {  	}  } -func TestCaesarNotAllowed(t *testing.T) { -	denyAll := func(r *http.Request) bool { return false } -	req := httptest.NewRequest("POST", "/", nil) -	resp := httptest.NewRecorder() - -	handler := handleCaesar(denyAll) -	handler(resp, req) - -	if resp.Code != http.StatusUnauthorized { -		t.Errorf("should not have been authorized") -	} - -	if len(resp.Body.Bytes()) != 0 { -		t.Errorf("should not have gotten a response body") -	} -} -  func TestCaesarBadRequest(t *testing.T) { -	allowAll := func(r *http.Request) bool { return true }  	req := httptest.NewRequest("GET", "/", nil)  	resp := httptest.NewRecorder() -	handler := handleCaesar(allowAll) +	handler := handleCaesar()  	handler(resp, req)  	if resp.Code != http.StatusBadRequest {  		t.Errorf("status should have been bad request, got %d", resp.Code)  | 
