Skip to content

Commit

Permalink
test(handlers): remove unneeded expectedError in TestHandlerPut
Browse files Browse the repository at this point in the history
  • Loading branch information
samlaf committed Nov 1, 2024
1 parent 919d944 commit 8bb3d26
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions server/handlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ func TestHandlerPut(t *testing.T) {
mockBehavior func()
expectedCode int
expectedBody string
expectError bool
}{
{
name: "Failure OP Mode Alt-DA - InternalServerError",
Expand All @@ -128,7 +127,6 @@ func TestHandlerPut(t *testing.T) {
},
expectedCode: http.StatusInternalServerError,
expectedBody: "",
expectError: true,
},
{
name: "Success OP Mode Alt-DA",
Expand All @@ -139,7 +137,6 @@ func TestHandlerPut(t *testing.T) {
},
expectedCode: http.StatusOK,
expectedBody: opGenericPrefixStr + testCommitStr,
expectError: false,
},
{
name: "Failure OP Mode Keccak256 - InternalServerError",
Expand All @@ -150,7 +147,6 @@ func TestHandlerPut(t *testing.T) {
},
expectedCode: http.StatusInternalServerError,
expectedBody: "",
expectError: true,
},
{
name: "Success OP Mode Keccak256",
Expand All @@ -161,7 +157,6 @@ func TestHandlerPut(t *testing.T) {
},
expectedCode: http.StatusOK,
expectedBody: "",
expectError: false,
},
{
name: "Failure Simple Commitment Mode - InternalServerError",
Expand All @@ -172,7 +167,6 @@ func TestHandlerPut(t *testing.T) {
},
expectedCode: http.StatusInternalServerError,
expectedBody: "",
expectError: true,
},
{
name: "Success Simple Commitment Mode",
Expand All @@ -183,7 +177,6 @@ func TestHandlerPut(t *testing.T) {
},
expectedCode: http.StatusOK,
expectedBody: simpleCommitmentPrefix + testCommitStr,
expectError: false,
},
}

Expand All @@ -205,12 +198,10 @@ func TestHandlerPut(t *testing.T) {
r.ServeHTTP(rec, req)

require.Equal(t, tt.expectedCode, rec.Code)
if !tt.expectError && tt.expectedBody != "" {
require.Equal(t, []byte(tt.expectedBody), rec.Body.Bytes())
}

if !tt.expectError && tt.expectedBody == "" {
require.Equal(t, []byte(nil), rec.Body.Bytes())
// We only test for bodies for 200s because error messages contain a lot of information
// that isn't very important to test (plus its annoying to always change if error msg changes slightly).
if tt.expectedCode == http.StatusOK {
require.Equal(t, tt.expectedBody, rec.Body.String())
}
})
}
Expand Down

0 comments on commit 8bb3d26

Please sign in to comment.