Added comments to db_test.go test functions
This commit is contained in:
parent
00f72df65f
commit
67680e2616
1 changed files with 18 additions and 0 deletions
|
@ -7,6 +7,7 @@ import (
|
|||
|
||||
// Tests are not guaranteed to be sequential
|
||||
|
||||
// setupState initializes a database instance with necessary setup for testing
|
||||
func setupState() (Database, error) {
|
||||
db := DbConnect(":memory:")
|
||||
err := db.Migrate()
|
||||
|
@ -16,11 +17,13 @@ func setupState() (Database, error) {
|
|||
return db, nil
|
||||
}
|
||||
|
||||
// TestDbConnect tests the connection to the database
|
||||
func TestDbConnect(t *testing.T) {
|
||||
db := DbConnect(":memory:")
|
||||
_ = db
|
||||
}
|
||||
|
||||
// TestDbAddUser tests the AddUser function of the database
|
||||
func TestDbAddUser(t *testing.T) {
|
||||
db, err := setupState()
|
||||
if err != nil {
|
||||
|
@ -32,6 +35,7 @@ func TestDbAddUser(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
// TestDbGetUserId tests the GetUserID function of the database
|
||||
func TestDbGetUserId(t *testing.T) {
|
||||
db, err := setupState()
|
||||
if err != nil {
|
||||
|
@ -52,6 +56,7 @@ func TestDbGetUserId(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
// TestDbAddProject tests the AddProject function of the database
|
||||
func TestDbAddProject(t *testing.T) {
|
||||
db, err := setupState()
|
||||
if err != nil {
|
||||
|
@ -64,6 +69,7 @@ func TestDbAddProject(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
// TestDbRemoveUser tests the RemoveUser function of the database
|
||||
func TestDbRemoveUser(t *testing.T) {
|
||||
db, err := setupState()
|
||||
if err != nil {
|
||||
|
@ -76,6 +82,7 @@ func TestDbRemoveUser(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
// TestPromoteToAdmin tests the PromoteToAdmin function of the database
|
||||
func TestPromoteToAdmin(t *testing.T) {
|
||||
db, err := setupState()
|
||||
if err != nil {
|
||||
|
@ -93,6 +100,7 @@ func TestPromoteToAdmin(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
// TestAddWeeklyReport tests the AddWeeklyReport function of the database
|
||||
func TestAddWeeklyReport(t *testing.T) {
|
||||
db, err := setupState()
|
||||
if err != nil {
|
||||
|
@ -115,6 +123,7 @@ func TestAddWeeklyReport(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
// TestAddUserToProject tests the AddUseToProject function of the database
|
||||
func TestAddUserToProject(t *testing.T) {
|
||||
db, err := setupState()
|
||||
if err != nil {
|
||||
|
@ -142,6 +151,7 @@ func TestAddUserToProject(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
// TestChangeUserRole tests the ChangeUserRole function of the database
|
||||
func TestChangeUserRole(t *testing.T) {
|
||||
db, err := setupState()
|
||||
if err != nil {
|
||||
|
@ -186,6 +196,7 @@ func TestChangeUserRole(t *testing.T) {
|
|||
|
||||
}
|
||||
|
||||
// TestGetAllUsersProject tests the GetAllUsersProject function of the database
|
||||
func TestGetAllUsersProject(t *testing.T) {
|
||||
db, err := setupState()
|
||||
if err != nil {
|
||||
|
@ -252,6 +263,7 @@ func TestGetAllUsersProject(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
// TestGetAllUsersApplication tests the GetAllUsersApplicsation function of the database
|
||||
func TestGetAllUsersApplication(t *testing.T) {
|
||||
db, err := setupState()
|
||||
if err != nil {
|
||||
|
@ -298,6 +310,7 @@ func TestGetAllUsersApplication(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
// TestGetProjectsForUser tests the GetProjectsForUser function of the database
|
||||
func TestGetProjectsForUser(t *testing.T) {
|
||||
db, err := setupState()
|
||||
if err != nil {
|
||||
|
@ -338,6 +351,7 @@ func TestGetProjectsForUser(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
// TestAddProject tests AddProject function of the database
|
||||
func TestAddProject(t *testing.T) {
|
||||
db, err := setupState()
|
||||
if err != nil {
|
||||
|
@ -373,6 +387,7 @@ func TestAddProject(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
// TestGetWeeklyReport tests GetWeeklyReport function of the database
|
||||
func TestGetWeeklyReport(t *testing.T) {
|
||||
db, err := setupState()
|
||||
if err != nil {
|
||||
|
@ -412,6 +427,7 @@ func TestGetWeeklyReport(t *testing.T) {
|
|||
// Check other fields similarly
|
||||
}
|
||||
|
||||
// TestSignWeeklyReport tests SignWeeklyReport function of the database
|
||||
func TestSignWeeklyReport(t *testing.T) {
|
||||
db, err := setupState()
|
||||
if err != nil {
|
||||
|
@ -484,6 +500,7 @@ func TestSignWeeklyReport(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
// TestSignWeeklyReportByAnotherProjectManager tests the scenario where a project manager attempts to sign a weekly report for a user who is not assigned to their project
|
||||
func TestSignWeeklyReportByAnotherProjectManager(t *testing.T) {
|
||||
db, err := setupState()
|
||||
if err != nil {
|
||||
|
@ -537,6 +554,7 @@ func TestSignWeeklyReportByAnotherProjectManager(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
// TestGetProject tests GetProject function of the database
|
||||
func TestGetProject(t *testing.T) {
|
||||
db, err := setupState()
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Reference in a new issue