romsar / gonertia

The Go adapter for Inertia.js
https://pkg.go.dev/github.com/romsar/gonertia
Other
88 stars 4 forks source link

testing.go:124: invalid inertia response #11

Closed romsar closed 3 months ago

romsar commented 3 months ago

Discussed in https://github.com/romsar/gonertia/discussions/10

Originally posted by **JensvandeWiel** July 31, 2024 I get this error while testing, i checked the source and used a website if the regex compiles. And on a website it does, but on the library it does not. Body: ```html
``` Test: ```go func TestSettingsInertiaHandler_Index_Error(t *testing.T) { conf, ok := config.GetConfig() if !ok { t.Fatal("failed to get config") } conf.Environment = config.EnvironmentProd ctx, e, rec := test.SetupEchoContext(http.MethodGet) ss := test.SetupSession(ctx) test.SetSession(ctx, ss) ctx.Set("user", map[string]interface{}{"id": uint(1)}) mockStore := new(test.MockCredentialsStore) mockStore.On("GetUserCredentials", uint(1)).Return(make([]models.Credential, 0), errors.New("some error")) i := frontend.RegisterFrontend(e, flash.NewFlashProvider()) h := handlers.NewSettingsInertiaHandler(i, mockStore) err := h.Index(ctx) assert.NoError(t, err) assert.Equal(t, http.StatusInternalServerError, rec.Code) t.Log(rec.Body.String()) assertable := gonertia.Assert(t, test.NewBody(rec.Body)) assertable.AssertComponent("Internal/ErrorPage") assertable.AssertProps(gonertia.Props{ "error": "some error", "errorCode": http.StatusInternalServerError, "errorDescription": http.StatusText(http.StatusInternalServerError), "prod": true, }) } ```
romsar commented 3 months ago

fixed