-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Open
Description
Bug Description
The problem is that I currently get test: got empty response in my go fiber tests. The tests worked reliably in v2. I don't know exactly what the problem is because they are just normal fiber.Handler methods.
How to Reproduce
Steps to reproduce the behavior:
- Go to https://github.com/ether/etherpad-go
- Check out the branch feature/fiber-v3
- Open the test/api/groups/groups_api_test.go
- Run the tests. They all error out with nil pointers for response
Expected Behavior
They should run as expected and return the expected json structure.
Fiber Version
v3.0.0
Code Snippet (optional)
func CreateGroup(store *lib.InitStore) fiber.Handler {
return func(c fiber.Ctx) error {
groupId := "g." + utils.RandomString(16)
err := store.Store.SaveGroup(groupId)
if err != nil {
return c.Status(500).JSON(errors.InternalServerError)
}
return c.JSON(GroupIDResponse{
GroupID: groupId,
})
}
}
Test:
func testCreateGroupSuccess(t *testing.T, tsStore testutils.TestDataStore) {
initStore := tsStore.ToInitStore()
groups.Init(initStore)
req := httptest.NewRequest("POST", "/admin/api/groups", nil)
resp, err := initStore.C.Test(req, fiber.TestConfig{Timeout: 5000})
assert.NoError(t, err)
assert.Equal(t, 200, resp.StatusCode)
var response groups.GroupIDResponse
body, _ := io.ReadAll(resp.Body)
_ = json.Unmarshal(body, &response)
assert.NotEmpty(t, response.GroupID)
assert.True(t, len(response.GroupID) > 2)
assert.Equal(t, "g.", response.GroupID[:2])
}Checklist:
- I agree to follow Fiber's Code of Conduct.
- I have checked for existing issues that describe my problem prior to opening this one.
- I understand that improperly formatted bug reports may be closed without explanation.
Reactions are currently unavailable