2024-02-12 12:40:49 +01:00
|
|
|
package database
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
2024-02-27 05:51:16 +01:00
|
|
|
// Tests are not guaranteed to be sequential
|
|
|
|
// Writing tests like this will bite you, eventually
|
|
|
|
|
2024-02-12 12:40:49 +01:00
|
|
|
func TestDbConnect(t *testing.T) {
|
|
|
|
db := DbConnect()
|
|
|
|
_ = db
|
|
|
|
}
|
2024-02-27 05:00:04 +01:00
|
|
|
|
|
|
|
func TestDbAddUser(t *testing.T) {
|
|
|
|
db := DbConnect()
|
|
|
|
err := db.AddUser("test", "password")
|
|
|
|
if err != nil {
|
|
|
|
t.Error("AddUser failed:", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-27 05:51:16 +01:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-27 07:59:42 +01:00
|
|
|
func TestDbAddProject(t *testing.T) {
|
|
|
|
db := DbConnect()
|
|
|
|
err := db.AddProject("test", "description", "test")
|
|
|
|
if err != nil {
|
|
|
|
t.Error("AddProject failed:", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-27 05:00:04 +01:00
|
|
|
func TestDbRemoveUser(t *testing.T) {
|
|
|
|
db := DbConnect()
|
|
|
|
err := db.RemoveUser("test")
|
|
|
|
if err != nil {
|
|
|
|
t.Error("RemoveUser failed:", err)
|
|
|
|
}
|
|
|
|
}
|