MCPcopy Create free account
hub / github.com/DATA-DOG/go-sqlmock / TestByteSliceArgument

Function TestByteSliceArgument

argument_test.go:39–58  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

37}
38
39func TestByteSliceArgument(t *testing.T) {
40 t.Parallel()
41 db, mock, err := New()
42 if err != nil {
43 t.Errorf("an error '%s' was not expected when opening a stub database connection", err)
44 }
45 defer db.Close()
46
47 username := []byte("user")
48 mock.ExpectExec("INSERT INTO users").WithArgs(username).WillReturnResult(NewResult(1, 1))
49
50 _, err = db.Exec("INSERT INTO users(username) VALUES (?)", username)
51 if err != nil {
52 t.Errorf("error '%s' was not expected, while inserting a row", err)
53 }
54
55 if err := mock.ExpectationsWereMet(); err != nil {
56 t.Errorf("there were unfulfilled expectations: %s", err)
57 }
58}

Callers

nothing calls this directly

Calls 8

NewFunction · 0.85
NewResultFunction · 0.85
WillReturnResultMethod · 0.80
ExpectExecMethod · 0.65
ExpectationsWereMetMethod · 0.65
CloseMethod · 0.45
WithArgsMethod · 0.45
ExecMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…