MCPcopy Index your code
hub / github.com/Masterminds/structable / TestPlainStructLoadWhere

Function TestPlainStructLoadWhere

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

Source from the content-addressed store, hash-verified

87}
88
89func TestPlainStructLoadWhere(t *testing.T) {
90
91 db := getLanguagesDb()
92
93 var lastId int64
94 if res, err := db.Exec("INSERT INTO languages (name, version, dt_release) VALUES ('Scala', '2.11.7', '2015-06-23')"); err != nil {
95 t.Fatalf("Sqlite Exec failed: %s", err)
96 } else if lastId, err = res.LastInsertId(); err != nil {
97 t.Fatalf("Sqlite LastInsertId failed: %s", err)
98 }
99
100 lsql := &Language{
101 Id: -1,
102 Name: "Scala",
103 Version: "2.11.7",
104 DtRelease: time.Date(2015, time.June, 23, 0, 0, 0, 0, time.UTC)}
105
106 l := &Language{Id: lastId}
107 l.Recorder = New(squirrel.NewStmtCacheProxy(db), "mysql").Bind("languages", l)
108 if err := l.LoadWhere("version = ?", "2.11.7"); err != nil {
109 t.Fatalf("Failed LoadWhere: %s", err)
110 }
111
112 lsql.Id = lastId
113 if !l.equals(lsql) {
114 t.Fatal("Loaded and inserted objects should be equivalent")
115 }
116}
117
118func TestPlainStructUpdate(t *testing.T) {
119

Callers

nothing calls this directly

Calls 7

equalsMethod · 0.95
getLanguagesDbFunction · 0.85
NewFunction · 0.85
ExecMethod · 0.80
LastInsertIdMethod · 0.80
BindMethod · 0.65
LoadWhereMethod · 0.65

Tested by

no test coverage detected