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

Function TestPlainStructLoad

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

Source from the content-addressed store, hash-verified

62}
63
64func TestPlainStructLoad(t *testing.T) {
65
66 db := getLanguagesDb()
67
68 lsql := &Language{}
69 if res, err := db.Exec("INSERT INTO languages (name, version, dt_release) VALUES ('Scala', '2.11.7', '2015-06-23')"); err != nil {
70 t.Fatalf("Sqlite Exec failed: %s", err)
71 } else if lsql.Id, err = res.LastInsertId(); err != nil {
72 t.Fatalf("Sqlite LastInsertId failed: %s", err)
73 }
74
75 l := &Language{Id: lsql.Id}
76 l.Recorder = New(squirrel.NewStmtCacheProxy(db), "mysql").Bind("languages", l)
77 if err := l.Load(); err != nil {
78 t.Fatalf("Failed Load: %s", err)
79 }
80
81 lsql.Name = "Scala"
82 lsql.Version = "2.11.7"
83 lsql.DtRelease = time.Date(2015, time.June, 23, 0, 0, 0, 0, time.UTC)
84 if !l.equals(lsql) {
85 t.Fatal("Loaded and inserted objects should be equivalent")
86 }
87}
88
89func TestPlainStructLoadWhere(t *testing.T) {
90

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
LoadMethod · 0.65

Tested by

no test coverage detected