func TestCreateMonth(t *testing.T) {
config := InitTestMonth(t)
newMonth := month.MonthCreate{
Year: 2000,
Month: 1,
}
t.Run("Should create month", func(t *testing.T) {
req := Request("POST", "/api/month", newMonth)
config.ServeHTTP(config.rec, req)
assert.Equal(t, http.StatusCreated, config.rec.Code)
})
t.Run("Should get conflict", func(t *testing.T) {
t.Parallel()
req := Request("POST", "/api/month", newMonth)
config.ServeHTTP(config.rec, req)
assert.Equal(t, http.StatusConflict, config.rec.Code)
})
}```
The first run: "Should create month" should create the data, and the second run, should get StatusConflict when creating with the same data. But i got `expected: 409, actual : 201` . It works fine if i run it separatedly. Any idea to make the second wait until the first finish?
#Golang testing: can't test "Should get conflict"
3 messages · Page 1 of 1 (latest)
If you remove the 'parallel' call from the 2nd run command shouldn´t it then just run in order? Or did you try that arleady?
ya tried already, didn't work