Skip to content

Commit

Permalink
fix old SA1006 lint errors
Browse files Browse the repository at this point in the history
Signed-off-by: Jonathan Holloway <[email protected]>
  • Loading branch information
loadtheaccumulator authored and ezr-ondrej committed Aug 20, 2024
1 parent fd7896a commit 7bd962a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 20 deletions.
3 changes: 1 addition & 2 deletions pkg/models/thirdpartyrepo.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package models

import (
"errors"
"fmt"
"regexp"
"strings"

Expand Down Expand Up @@ -66,7 +65,7 @@ func (t *ThirdPartyRepo) ValidateRequest() error {
return errors.New(RepoNameCantBeInvalidMessage)
}
if !ValidateRepoURL(t.URL) {
return fmt.Errorf(InvalidURL)
return errors.New(InvalidURL)
}
return nil
}
Expand Down
36 changes: 18 additions & 18 deletions pkg/routes/images_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func TestCreateWasCalledWithNameNotSet(t *testing.T) {
var buf bytes.Buffer
err := json.NewEncoder(&buf).Encode(jsonImage)
if err != nil {
t.Errorf(err.Error())
t.Error(err.Error())
}
req, err := http.NewRequest("POST", "/", &buf)
if err != nil {
Expand Down Expand Up @@ -119,7 +119,7 @@ func TestCreate(t *testing.T) {
var buf bytes.Buffer
err := json.NewEncoder(&buf).Encode(jsonImage)
if err != nil {
t.Errorf(err.Error())
t.Error(err.Error())
}
req, err := http.NewRequest("POST", "/", &buf)
if err != nil {
Expand Down Expand Up @@ -167,7 +167,7 @@ func TestCreateWithInvalidPackageName(t *testing.T) {
var buf bytes.Buffer
err := json.NewEncoder(&buf).Encode(jsonImage)
if err != nil {
t.Errorf(err.Error())
t.Error(err.Error())
}
req, err := http.NewRequest("POST", "/", &buf)
if err != nil {
Expand Down Expand Up @@ -212,7 +212,7 @@ func TestCreateWithThirdPartyRepositoryInfoInvalid(t *testing.T) {
var buf bytes.Buffer
err := json.NewEncoder(&buf).Encode(jsonImage)
if err != nil {
t.Errorf(err.Error())
t.Error(err.Error())
}
req, err := http.NewRequest("POST", "/", &buf)
if err != nil {
Expand Down Expand Up @@ -257,7 +257,7 @@ func TestCreateWithImageNameAlreadyExist(t *testing.T) {
var buf bytes.Buffer
err := json.NewEncoder(&buf).Encode(jsonImage)
if err != nil {
t.Errorf(err.Error())
t.Error(err.Error())
}
req, err := http.NewRequest("POST", "/", &buf)
if err != nil {
Expand Down Expand Up @@ -312,12 +312,12 @@ func TestGetStatus(t *testing.T) {
}
respBody, err := io.ReadAll(rr.Body)
if err != nil {
t.Errorf(err.Error())
t.Error(err.Error())
}

err = json.Unmarshal(respBody, &ir)
if err != nil {
t.Errorf(err.Error())
t.Error(err.Error())
}
}

Expand Down Expand Up @@ -362,12 +362,12 @@ func TestGetImageDetailsById(t *testing.T) {
var ir ImageResponse
respBody, err := io.ReadAll(rr.Body)
if err != nil {
t.Errorf(err.Error())
t.Error(err.Error())
}

err = json.Unmarshal(respBody, &ir)
if err != nil {
t.Errorf(err.Error())
t.Error(err.Error())
}

if ir.Packages != 1 {
Expand Down Expand Up @@ -430,12 +430,12 @@ func TestGetImageDetailsByIdWithUpdate(t *testing.T) {
var ir ImageResponse
respBody, err := io.ReadAll(rr.Body)
if err != nil {
t.Errorf(err.Error())
t.Error(err.Error())
}

err = json.Unmarshal(respBody, &ir)
if err != nil {
t.Errorf(err.Error())
t.Error(err.Error())
}

if ir.Packages != 1 {
Expand Down Expand Up @@ -692,12 +692,12 @@ func TestGetRepoForImage(t *testing.T) {
var repoResponse models.Repo
respBody, err := io.ReadAll(rr.Body)
if err != nil {
t.Errorf(err.Error())
t.Error(err.Error())
}

err = json.Unmarshal(respBody, &repoResponse)
if err != nil {
t.Errorf(err.Error())
t.Error(err.Error())
}

if repoResponse.ID != testRepo.ID {
Expand Down Expand Up @@ -760,12 +760,12 @@ func TestGetImageByOstree(t *testing.T) {
var ir models.Image
respBody, err := io.ReadAll(rr.Body)
if err != nil {
t.Errorf(err.Error())
t.Error(err.Error())
}

err = json.Unmarshal(respBody, &ir)
if err != nil {
t.Errorf(err.Error())
t.Error(err.Error())
}

if ir.ID != testImage.ID {
Expand Down Expand Up @@ -793,7 +793,7 @@ func TestPostCheckImageNameAlreadyExist(t *testing.T) {
var buf bytes.Buffer
err := json.NewEncoder(&buf).Encode(jsonImage)
if err != nil {
t.Errorf(err.Error())
t.Error(err.Error())
}
req, err := http.NewRequest("POST", "/", &buf)
if err != nil {
Expand Down Expand Up @@ -842,7 +842,7 @@ func TestPostCheckImageNameDoesNotExist(t *testing.T) {
var buf bytes.Buffer
err := json.NewEncoder(&buf).Encode(jsonImage)
if err != nil {
t.Errorf(err.Error())
t.Error(err.Error())
}
req, err := http.NewRequest("POST", "/checkImageName", &buf)
if err != nil {
Expand All @@ -865,7 +865,7 @@ func TestPostCheckImageNameDoesNotExist(t *testing.T) {
handler.ServeHTTP(rr, req)
respBody, err := io.ReadAll(rr.Body)
if err != nil {
t.Errorf(err.Error())
t.Error(err.Error())
}
var ir bool
if err := json.Unmarshal(respBody, &ir); err != nil {
Expand Down

0 comments on commit 7bd962a

Please sign in to comment.