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

Function TestPlainStructExists

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

Source from the content-addressed store, hash-verified

171}
172
173func TestPlainStructExists(t *testing.T) {
174
175 db := getLanguagesDb()
176
177 l := &Language{Id: 1}
178 l.Recorder = New(squirrel.NewStmtCacheProxy(db), "mysql").Bind("languages", l)
179
180 if exists, err := l.Exists(); err != nil {
181 t.Fatalf("Failed Exists: %s", err)
182 } else if exists {
183 t.Fatal("Exists should return false")
184 }
185
186 var lastId int64
187 if res, err := db.Exec("INSERT INTO languages (name, version, dt_release) VALUES ('Scala', '2.11.7', '2015-06-23')"); err != nil {
188 t.Fatalf("Sqlite Exec failed: %s", err)
189 } else if lastId, err = res.LastInsertId(); err != nil {
190 t.Fatalf("Sqlite LastInsertId failed: %s", err)
191 }
192
193 l.Id = lastId
194 if exists, err := l.Exists(); err != nil {
195 t.Fatalf("Failed Exists: %s", err)
196 } else if !exists {
197 t.Fatal("Exists should return true")
198 }
199}
200
201func TestPlainStructExistsWhere(t *testing.T) {
202

Callers

nothing calls this directly

Calls 6

getLanguagesDbFunction · 0.85
NewFunction · 0.85
ExecMethod · 0.80
LastInsertIdMethod · 0.80
BindMethod · 0.65
ExistsMethod · 0.65

Tested by

no test coverage detected