Tests for AddProject to ensure creator is Manager

This commit is contained in:
Imbus 2024-03-20 18:47:37 +01:00
parent 45761dadcb
commit 3525598df2

View file

@ -711,3 +711,31 @@ func TestChangeUserName(t *testing.T) {
t.Error("Expected GetUserId to fail for the old name, but it didn't") t.Error("Expected GetUserId to fail for the old name, but it didn't")
} }
} }
func TestEnsureManagerOfCreatedProject(t *testing.T) {
db, err := setupState()
if err != nil {
t.Error("setupState failed:", err)
}
// Add a user
err = db.AddUser("testuser", "password")
if err != nil {
t.Error("AddUser failed:", err)
}
// Add a project
err = db.AddProject("testproject", "description", "testuser")
if err != nil {
t.Error("AddProject failed:", err)
}
managerState, err := db.IsProjectManager("testuser", "testproject")
if err != nil {
t.Error("IsProjectManager failed:", err)
}
if !managerState {
t.Error("Expected testuser to be a project manager, but it's not.")
}
}