Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Test
on:
on:
push:
branches: [ main ]
branches: [main]
pull_request:

jobs:
Expand All @@ -13,8 +13,12 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.21.3'
go-version: "1.21.3"
- name: Install dependencies
run: go get .
- name: Test with the Go CLI
- name: Lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.60
- name: Test
run: go test ./...
8 changes: 4 additions & 4 deletions internal/cli/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func TestCombineBeforeFuncs(t *testing.T) {

before_func := CombineBeforeFuncs(mockBeforeFuncs.Func1, mockBeforeFuncs.Func2)

before_func(nil)
_ = before_func(nil)

mockBeforeFuncs.AssertExpectations(t)
}
Expand Down Expand Up @@ -47,7 +47,7 @@ func TestConfigureLogs(t *testing.T) {
flag.Bool("verbose", input, "")
context := cli.NewContext(nil, flag, nil)

ConfigureLogs(context)
_ = ConfigureLogs(context)

assert.Equal(t, zerolog.GlobalLevel(), want)
}
Expand All @@ -69,10 +69,10 @@ func TestConfigFileLoaderNoFile(t *testing.T) {
func TestLogArguments(t *testing.T) {
flag := flag.NewFlagSet("flag", flag.ContinueOnError)
flag.String("some-flag", "", "")
flag.Set("some-flag", "value")
_ = flag.Set("some-flag", "value")
context := cli.NewContext(nil, flag, nil)

LogArguments(context)
_ = LogArguments(context)

// How to assert that the log message was correct?
}
2 changes: 1 addition & 1 deletion internal/gitlab/gitlab_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ func (c *mockClient) ListProjectIssues(projectId interface{}, opt *gitlab.ListPr
args := c.Called(projectId, opt, options)
var r *gitlab.Response
if resp := args.Get(1); resp != nil {
resp = args.Get(1).(*gitlab.Response)
r = args.Get(1).(*gitlab.Response)
}
return args.Get(0).([]*gitlab.Issue), r, args.Error(2)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/publish/to_gitlab_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func TestPublishAsGitlabIssues(t *testing.T) {
},
}

PublishAsGitlabIssues(reports, mockGitlabService)
_ = PublishAsGitlabIssues(reports, mockGitlabService)
mockGitlabService.AssertExpectations(t)

t.Run("FillsTheIssueUrl", func(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion internal/publish/to_slack_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func TestPublishAsSpecificChannelSlackMessage(t *testing.T) {
ProjectConfig: scanner.ProjectConfig{SlackChannel: "channel"},
}

PublishAsSpecificChannelSlackMessage([]scanner.Report{report}, mockSlackService)
_ = PublishAsSpecificChannelSlackMessage([]scanner.Report{report}, mockSlackService)

mockSlackService.AssertExpectations(t)
mockSlackService.AssertNumberOfCalls(t, "PostMessage", 1)
Expand Down
3 changes: 2 additions & 1 deletion internal/shell/shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ func (c *shellCommandRunner) Run(in CommandInput) (CommandOutput, error) {
if in.Timeout == 0 {
in.Timeout = defaultTimeout
}
ctx, _ := context.WithTimeout(context.Background(), in.Timeout)
ctx, cancel := context.WithTimeout(context.Background(), in.Timeout)
defer cancel()
cmd := exec.CommandContext(ctx, in.Name, in.Args...)
out, err := cmd.Output()

Expand Down
7 changes: 5 additions & 2 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@ run *ARGS:
GITLAB_TOKEN=$GITLAB_TOKEN go run . {{ARGS}}

alias t := test
test:
go test ./...
test *ARGS="./...":
go test {{ARGS}}

lint:
golangci-lint run ./...
Loading