(t *testing.T)
| 1893 | } |
| 1894 | |
| 1895 | func TestSelectReset(t *testing.T) { |
| 1896 | RunWithSchema(defaultSchema, t, func(db *DB, t *testing.T, now string) { |
| 1897 | loadDefaultFixture(db, t) |
| 1898 | |
| 1899 | filledDest := []string{"a", "b", "c"} |
| 1900 | err := db.Select(&filledDest, "SELECT first_name FROM person ORDER BY first_name ASC;") |
| 1901 | if err != nil { |
| 1902 | t.Fatal(err) |
| 1903 | } |
| 1904 | if len(filledDest) != 2 { |
| 1905 | t.Errorf("Expected 2 first names, got %d.", len(filledDest)) |
| 1906 | } |
| 1907 | expected := []string{"Jason", "John"} |
| 1908 | for i, got := range filledDest { |
| 1909 | if got != expected[i] { |
| 1910 | t.Errorf("Expected %d result to be %s, but got %s.", i, expected[i], got) |
| 1911 | } |
| 1912 | } |
| 1913 | |
| 1914 | var emptyDest []string |
| 1915 | err = db.Select(&emptyDest, "SELECT first_name FROM person WHERE first_name = 'Jack';") |
| 1916 | if err != nil { |
| 1917 | t.Fatal(err) |
| 1918 | } |
| 1919 | // Verify that selecting 0 rows into a nil target didn't create a |
| 1920 | // non-nil slice. |
| 1921 | if emptyDest != nil { |
| 1922 | t.Error("Expected emptyDest to be nil") |
| 1923 | } |
| 1924 | }) |
| 1925 | } |
nothing calls this directly
no test coverage detected