MCPcopy Create free account
hub / github.com/Masterminds/structable / TestPlainStructExistsWhere

Function TestPlainStructExistsWhere

sqlite_pod_test.go:201–223  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

199}
200
201func TestPlainStructExistsWhere(t *testing.T) {
202
203 db := getLanguagesDb()
204
205 if _, err := db.Exec("INSERT INTO languages (name, version, dt_release) VALUES ('Scala', '2.11.7', '2015-06-23')"); err != nil {
206 t.Fatalf("Sqlite Exec failed: %s", err)
207 }
208
209 l := &Language{}
210 l.Recorder = New(squirrel.NewStmtCacheProxy(db), "mysql").Bind("languages", l)
211
212 if exists, err := l.ExistsWhere("Name = ?", "Go"); err != nil {
213 t.Fatalf("Failed ExistsWhere: %s", err)
214 } else if exists {
215 t.Fatal("ExistsWhere should return false")
216 }
217
218 if exists, err := l.ExistsWhere("Name = ?", "Scala"); err != nil {
219 t.Fatalf("Failed Exists: %s", err)
220 } else if !exists {
221 t.Fatal("Exists should return true")
222 }
223}
224
225func getLanguagesDb() *sql.DB {
226

Callers

nothing calls this directly

Calls 5

getLanguagesDbFunction · 0.85
NewFunction · 0.85
ExecMethod · 0.80
BindMethod · 0.65
ExistsWhereMethod · 0.65

Tested by

no test coverage detected