TTime/backend/internal/database/db_test.go

43 lines
731 B
Go

package database
import (
"testing"
)
// Tests are not guaranteed to be sequential
// Writing tests like this will bite you, eventually
func TestDbConnect(t *testing.T) {
db := DbConnect()
_ = db
}
func TestDbAddUser(t *testing.T) {
db := DbConnect()
err := db.AddUser("test", "password")
if err != nil {
t.Error("AddUser failed:", err)
}
}
func TestDbGetUserId(t *testing.T) {
db := DbConnect()
var id int
id, err := db.GetUserId("test")
if err != nil {
t.Error("GetUserId failed:", err)
}
if id != 1 {
t.Error("GetUserId failed: expected 1, got", id)
}
}
func TestDbRemoveUser(t *testing.T) {
db := DbConnect()
err := db.RemoveUser("test")
if err != nil {
t.Error("RemoveUser failed:", err)
}
}