mirror of
https://github.com/simon987/task_tracker.git
synced 2025-12-14 15:29:02 +00:00
Some error handling work
This commit is contained in:
@@ -156,6 +156,9 @@ func getSessionCtx(username string, password string, admin bool) *http.Client {
|
||||
|
||||
if admin {
|
||||
manager, _ := testApi.Database.ValidateCredentials([]byte(username), []byte(password))
|
||||
if manager == nil {
|
||||
return nil
|
||||
}
|
||||
manager.WebsiteAdmin = true
|
||||
testApi.Database.UpdateManager(manager)
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ func TestWebHookDontUpdateVersion(t *testing.T) {
|
||||
|
||||
getResp := getProjectAsAdmin(resp.Id).Content
|
||||
|
||||
if getResp.Project.Version != "old" {
|
||||
if getResp.Project == nil || getResp.Project.Version != "old" {
|
||||
t.Error()
|
||||
}
|
||||
}
|
||||
@@ -93,7 +93,7 @@ func TestWebHookUpdateVersion(t *testing.T) {
|
||||
|
||||
getResp := getProjectAsAdmin(resp.Id).Content
|
||||
|
||||
if getResp.Project.Version != "new" {
|
||||
if getResp.Project == nil || getResp.Project.Version != "new" {
|
||||
t.Error()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,8 +139,9 @@ func TestGetLogs(t *testing.T) {
|
||||
t.Error()
|
||||
}
|
||||
|
||||
if len(*r.Content.Logs) <= 0 {
|
||||
if r.Content.Logs == nil || len(*r.Content.Logs) <= 0 {
|
||||
t.Error()
|
||||
return
|
||||
}
|
||||
|
||||
debugFound := false
|
||||
|
||||
@@ -37,12 +37,13 @@ func TestCreateGetProject(t *testing.T) {
|
||||
|
||||
getResp := getProjectAsAdmin(id).Content
|
||||
|
||||
if getResp.Project.Id != id {
|
||||
if getResp.Project == nil || getResp.Project.Id != id {
|
||||
t.Error()
|
||||
}
|
||||
|
||||
if getResp.Project.Name != "Test name" {
|
||||
if getResp.Project == nil || getResp.Project.Name != "Test name" {
|
||||
t.Error()
|
||||
return
|
||||
}
|
||||
|
||||
if getResp.Project.Version != "Test Version" {
|
||||
@@ -147,8 +148,9 @@ func TestUpdateProjectValid(t *testing.T) {
|
||||
|
||||
proj := getProjectAsAdmin(pid).Content
|
||||
|
||||
if proj.Project.Public != false {
|
||||
if proj.Project == nil || proj.Project.Public != false {
|
||||
t.Error()
|
||||
return
|
||||
}
|
||||
if proj.Project.Motd != "MotdB" {
|
||||
t.Error()
|
||||
@@ -314,7 +316,8 @@ func TestHiddenProjectsNotShownInList(t *testing.T) {
|
||||
}, testUserCtx)
|
||||
|
||||
if r.Ok != true {
|
||||
t.Error()
|
||||
t.Fail()
|
||||
return
|
||||
}
|
||||
|
||||
list := getProjectList(nil)
|
||||
@@ -417,6 +420,11 @@ func TestUserWithReadAccessShouldSeeHiddenProjectInList(t *testing.T) {
|
||||
|
||||
list := getProjectList(testUserCtx)
|
||||
|
||||
if list.Content.Projects == nil {
|
||||
t.Fail()
|
||||
return
|
||||
}
|
||||
|
||||
found := false
|
||||
for _, p := range *list.Content.Projects {
|
||||
if p.Id == pHidden.Content.Id {
|
||||
@@ -441,6 +449,11 @@ func TestAdminShouldSeeHiddenProjectInList(t *testing.T) {
|
||||
|
||||
list := getProjectList(testAdminCtx)
|
||||
|
||||
if list.Content.Projects == nil {
|
||||
t.Fail()
|
||||
return
|
||||
}
|
||||
|
||||
found := false
|
||||
for _, p := range *list.Content.Projects {
|
||||
if p.Id == pHidden.Content.Id {
|
||||
|
||||
Reference in New Issue
Block a user