call to ExecQuery ... was not expected; call to Rollback transaction was not expecte in gorm with postgres
call to ExecQuery 'INSERT INTO "users" ("id","user_name","pass_word","email","role","name","created_at","updated_at") VALUES ($1,$2,$3,$4,$5,$6,$7,$8)' with args [{Name: Ordinal:1 Value:a8813f4a-bd82-4dd2-bdd9-fbcf0aa7787f} {Name: Ordinal:2 Value:test} {Name: Ordinal:3 Value:12345} {Name: Ordinal:4 Value:testemail} {Name: Ordinal:5 Value:admin} {Name: Ordinal:6 Value:test} {Name: Ordinal:7 Value:2020-11-18 16:36:03.948311091 +0330 +0330 m=+0.005700519} {Name: Ordinal:8 Value:2020-11-18 16:36:03.94831117 +0330 +0330 m=+0.005700600}] was not expected; call to Rollback transaction was not expected [0.300ms] [rows:0] INSERT INTO "users" ("id","user_name","pass_word","email","role","name","created_at","updated_at") VALUES ('a8813f4a-bd82-4dd2-bdd9-fbcf0aa7787f','test','12345','testemail','admin','test','2020-11-18 16:36:03.948','2020-11-18 16:36:03.948') --- FAIL: TestSignUp (0.00s) postgersql_test.go:96: Failed to insert to gorm db, got error: call to ExecQuery 'INSERT INTO "users" ("id","user_name","pass_word","email","role","name","created_at","updated_at") VALUES ($1,$2,$3,$4,$5,$6,$7,$8)' with args [{Name: Ordinal:1 Value:a8813f4a-bd82-4dd2-bdd9-fbcf0aa7787f} {Name: Ordinal:2 Value:test} {Name: Ordinal:3 Value:12345} {Name: Ordinal:4 Value:testemail} {Name: Ordinal:5 Value:admin} {Name: Ordinal:6 Value:test} {Name: Ordinal:7 Value:2020-11-18 16:36:03.948311091 +0330 +0330 m=+0.005700519} {Name: Ordinal:8 Value:2020-11-18 16:36:03.94831117 +0330 +0330 m=+0.005700600}] was not expected; call to Rollback transaction was not expected postgersql_test.go:101: Failed to meet expectations, got error: there is a remaining expectation which was not matched: ExpectedQuery => expecting Query, QueryContext or QueryRow which: - matches sql: 'INSERT INTO "users" ("id","user_name", "pass_word","email","role","name","created_at","updated_at") VALUES ($1,$2,$3,$4,$5,$6,$7,$8) RETURNING "users"."id";' - is with arguments: 0 - a8813f4a-bd82-4dd2-bdd9-fbcf0aa7787f 1 - test 2 - 12345 3 - testemail 4 - admin 5 - test 6 - {} 7 - {} - should return rows: row 0 - [a8813f4a-bd82-4dd2-bdd9-fbcf0aa7787f] FAIL
I have the same issue
I also have the same issue
Looking at your error it has
call to ExecQuery 'INSERT INTO "users" ("id","user_name","pass_word","email","role","name","created_at","updated_at") VALUES ($1,$2,$3,$4,$5,$6,$7,$8)' ...
expecting Query, QueryContext or QueryRow which:
- matches sql: 'INSERT INTO "users" ("id","user_name", "pass_word","email","role","name","created_at","updated_at") VALUES ($1,$2,$3,$4,$5,$6,$7,$8) RETURNING "users"."id";'
The query your code is running does not end in the 'RETURNING "users"."id";' that exists in your test.