func TestDeleteAccount(t *testing.T) { account1 := createRandomAccount(t) err := testQueries.DeleteAccount(context.Background(), account1.ID) require.NoError(t, err) account2, err := testQueries.GetAccount(context.Background(), account1.ID) require.Error(t, err) require.EqualError(t, err, sql.ErrNoRows.Error()) require.Empty(t, account2) }=== RUN TestDeleteAccount /zdata/Github/zimplebank/db/account_test.go:77: Error Trace: /zdata/Github/zimplebank/db/account_test.go:77 Error: Error message not equal: expected: "sql: no rows in result set" actual : "no rows in result set" Test: TestDeleteAccount --- FAIL: TestDeleteAccount (0.01s)
func TestDeleteAccount(t *testing.T) { account1 := createRandomAccount(t) err := testQueries.DeleteAccount(context.Background(), account1.ID) require.NoError(t, err) account2, err := testQueries.GetAccount(context.Background(), account1.ID) require.Error(t, err) require.ErrorContains(t, sql.ErrNoRows, err.Error()) require.Empty(t, account2) }=== RUN TestDeleteAccount --- PASS: TestDeleteAccount (0.01s) PASS ok github.com/ZhangZhihuiAAA/zimplebank/db 0.014s 标签:Background,err,require,equal,TestDeleteAccount,account1,Error,message,Zimp From: https://www.cnblogs.com/zhangzhihui/p/17865716.html