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

Function TestPlainStructUpdate

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

Source from the content-addressed store, hash-verified

116}
117
118func TestPlainStructUpdate(t *testing.T) {
119
120 db := getLanguagesDb()
121
122 var lastId int64
123 if res, err := db.Exec("INSERT INTO languages (name, version, dt_release) VALUES ('Scala', '2.11.7', '2015-06-23')"); err != nil {
124 t.Fatalf("Sqlite Exec failed: %s", err)
125 } else if lastId, err = res.LastInsertId(); err != nil {
126 t.Fatalf("Sqlite LastInsertId failed: %s", err)
127 }
128
129 l := &Language{
130 Id: lastId,
131 Name: "Go",
132 Version: "1.4",
133 DtRelease: time.Date(2014, time.June, 18, 0, 0, 0, 0, time.UTC)}
134
135 l.Recorder = New(squirrel.NewStmtCacheProxy(db), "mysql").Bind("languages", l)
136 if err := l.Update(); err != nil {
137 t.Fatalf("Failed Update: %s", err)
138 }
139
140 lsql := new(Language)
141 lsql.loadFromSql(lastId, db)
142 if !l.equals(lsql) {
143 t.Fatal("Loaded and updated objects should be equivalent")
144 }
145}
146
147func TestPlainStructDelete(t *testing.T) {
148

Callers

nothing calls this directly

Calls 8

equalsMethod · 0.95
getLanguagesDbFunction · 0.85
NewFunction · 0.85
ExecMethod · 0.80
LastInsertIdMethod · 0.80
BindMethod · 0.65
UpdateMethod · 0.65
loadFromSqlMethod · 0.45

Tested by

no test coverage detected