package fixtures import ( "testing" "time" lishwist "lishwist/core" "github.com/ncruces/go-sqlite3/vfs/memdb" ) func TestInit(t *testing.T) error { uri := memdb.TestDB(t) return lishwist.Init(uri) } // Deprecated: This function also inits the test, which prevents it from being used more than once per test func Login(t *testing.T, username, password string) *lishwist.Session { uri := memdb.TestDB(t) err := lishwist.Init(uri) if err != nil { t.Fatalf("Failed to init db: %s\n", err) } _, err = lishwist.Register(username, password) if err != nil { t.Fatalf("Failed to register on login fixture: %s\n", err) } session, err := lishwist.Login(username, password, time.Hour*24) if err != nil { t.Fatalf("Failed to login on fixture: %s\n", err) } return session } func Login2(t *testing.T, username, password string) *lishwist.Session { _, err := lishwist.Register(username, password) if err != nil { t.Fatalf("Failed to register on login fixture: %s\n", err) } session, err := lishwist.Login(username, password, time.Hour*24) if err != nil { t.Fatalf("Failed to login on fixture: %s\n", err) } return session }