ardanlabs / service

Starter-kit for writing services in Go using Kubernetes.
https://www.ardanlabs.com
Apache License 2.0
3.59k stars 649 forks source link

Transaction error 500 when testing transaction with validation error 400 #391

Closed rmsj closed 5 months ago

rmsj commented 5 months ago

If a new test is added to the transaction api:

func create400(sd apitest.SeedData) []apitest.Table { table := []apitest.Table{ { Name: "basic", URL: "/v1/tranexample", Token: sd.Admins[0].Token, Method: http.MethodPost, StatusCode: http.StatusBadRequest, Input: &tranapp.NewTran{ Product: tranapp.NewProduct{ Quantity: 10, }, User: tranapp.NewUser{ Name: "Bill Kennedy", Email: "bill@ardanlabs.com", Roles: []string{"ADMIN"}, Department: "IT", Password: "123", PasswordConfirm: "123", }, }, GotResp: &tranapp.Product{}, ExpResp: nil, //TODO, CmpFunc: func(got any, exp any) string { return nil // TODO }, }, } return table }

The error that transaction.go sends is a 500 error, overriding the 400 from the validation. See transaction.go, line 40

PS.: Sorry, can't get format to behave.

ardan-bkennedy commented 5 months ago

I can reproduce this. Transactions have created all sort of chaos. I am looking into this now. THANKS

ardan-bkennedy commented 5 months ago

Ok, I just pushed a fix. This was a great catch.