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

Function TestAddRowExpectPanic

rows_test.go:733–756  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

731}
732
733func TestAddRowExpectPanic(t *testing.T) {
734 t.Parallel()
735
736 const expectedPanic = "Expected number of values to match number of columns: expected 1, actual 2"
737 values := []driver.Value{
738 "John",
739 "Jane",
740 }
741
742 defer func() {
743 if r := recover(); r != nil {
744 if r != expectedPanic {
745 t.Fatalf("panic message did not match expected: expected '%s', actual '%s'", r, expectedPanic)
746 }
747
748 return
749 }
750 t.Fatalf("expected panic: %s", expectedPanic)
751 }()
752
753 rows := NewRows([]string{"id", "name"})
754 // Note missing spread "..."
755 rows.AddRow(values)
756}
757
758func ExampleRows_AddRows() {
759 db, mock, err := New()

Callers

nothing calls this directly

Calls 2

AddRowMethod · 0.95
NewRowsFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…