Fix golangci-lint
This commit is contained in:
parent
d87bdd451d
commit
cc3761a5e1
36
.golangci.yml
Normal file
36
.golangci.yml
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
---
|
||||||
|
linters:
|
||||||
|
enable:
|
||||||
|
- errname
|
||||||
|
- errorlint
|
||||||
|
- exhaustive
|
||||||
|
- gofumpt
|
||||||
|
- goimports
|
||||||
|
- goprintffuncname
|
||||||
|
- misspell
|
||||||
|
- gomnd
|
||||||
|
- tagliatelle
|
||||||
|
- tenv
|
||||||
|
- testpackage
|
||||||
|
- thelper
|
||||||
|
- tparallel
|
||||||
|
- unconvert
|
||||||
|
- wrapcheck
|
||||||
|
- wsl
|
||||||
|
disable:
|
||||||
|
- gochecknoglobals
|
||||||
|
|
||||||
|
linters-settings:
|
||||||
|
gosec:
|
||||||
|
excludes:
|
||||||
|
- G204
|
||||||
|
tagliatelle:
|
||||||
|
case:
|
||||||
|
rules:
|
||||||
|
yaml: snake
|
||||||
|
|
||||||
|
issues:
|
||||||
|
exclude-rules:
|
||||||
|
- path: _test\.go
|
||||||
|
linters:
|
||||||
|
- gosec
|
@ -7,11 +7,9 @@ repos:
|
|||||||
- id: trailing-whitespace
|
- id: trailing-whitespace
|
||||||
- id: end-of-file-fixer
|
- id: end-of-file-fixer
|
||||||
- id: check-merge-conflict
|
- id: check-merge-conflict
|
||||||
- repo: https://github.com/dnephin/pre-commit-golang
|
- repo: https://github.com/golangci/golangci-lint
|
||||||
rev: v0.5.1
|
rev: v1.52.2
|
||||||
hooks:
|
hooks:
|
||||||
- id: go-fmt
|
|
||||||
- id: go-imports
|
|
||||||
- id: golangci-lint
|
- id: golangci-lint
|
||||||
- repo: https://github.com/IamTheFij/docker-pre-commit
|
- repo: https://github.com/IamTheFij/docker-pre-commit
|
||||||
rev: v3.0.1
|
rev: v3.0.1
|
||||||
|
@ -9,6 +9,8 @@ services:
|
|||||||
command: ["-watch", "10s", "-debug"]
|
command: ["-watch", "10s", "-debug"]
|
||||||
volumes:
|
volumes:
|
||||||
- /var/run/docker.sock:/var/run/docker.sock:ro
|
- /var/run/docker.sock:/var/run/docker.sock:ro
|
||||||
|
environment:
|
||||||
|
DOCKER_API_VERSION: 1.45
|
||||||
|
|
||||||
start_echoer:
|
start_echoer:
|
||||||
image: busybox:latest
|
image: busybox:latest
|
||||||
|
11
main_test.go
11
main_test.go
@ -51,6 +51,8 @@ type FakeDockerClient struct {
|
|||||||
|
|
||||||
// AssertFakeCalls checks expected against actual calls to fake methods
|
// AssertFakeCalls checks expected against actual calls to fake methods
|
||||||
func (fakeClient FakeDockerClient) AssertFakeCalls(t *testing.T, expectedCalls map[string][]FakeCall, message string) {
|
func (fakeClient FakeDockerClient) AssertFakeCalls(t *testing.T, expectedCalls map[string][]FakeCall, message string) {
|
||||||
|
t.Helper()
|
||||||
|
|
||||||
if !reflect.DeepEqual(fakeClient.FakeCalls, expectedCalls) {
|
if !reflect.DeepEqual(fakeClient.FakeCalls, expectedCalls) {
|
||||||
t.Errorf(
|
t.Errorf(
|
||||||
"%s: Expected and actual calls do not match. Expected %+v Actual %+v",
|
"%s: Expected and actual calls do not match. Expected %+v Actual %+v",
|
||||||
@ -161,6 +163,8 @@ func NewFakeDockerClient() *FakeDockerClient {
|
|||||||
|
|
||||||
// ErrorUnequal checks that two values are equal and fails the test if not
|
// ErrorUnequal checks that two values are equal and fails the test if not
|
||||||
func ErrorUnequal(t *testing.T, expected interface{}, actual interface{}, message string) {
|
func ErrorUnequal(t *testing.T, expected interface{}, actual interface{}, message string) {
|
||||||
|
t.Helper()
|
||||||
|
|
||||||
if expected != actual {
|
if expected != actual {
|
||||||
t.Errorf("%s Expected: %+v Actual: %+v", message, expected, actual)
|
t.Errorf("%s Expected: %+v Actual: %+v", message, expected, actual)
|
||||||
}
|
}
|
||||||
@ -345,6 +349,7 @@ func TestQueryScheduledJobs(t *testing.T) {
|
|||||||
|
|
||||||
t.Logf("Expected jobs: %+v, Actual jobs: %+v", c.expectedJobs, jobs)
|
t.Logf("Expected jobs: %+v, Actual jobs: %+v", c.expectedJobs, jobs)
|
||||||
ErrorUnequal(t, len(c.expectedJobs), len(jobs), "Job lengths don't match")
|
ErrorUnequal(t, len(c.expectedJobs), len(jobs), "Job lengths don't match")
|
||||||
|
|
||||||
for i, job := range jobs {
|
for i, job := range jobs {
|
||||||
ErrorUnequal(t, c.expectedJobs[i], job, "Job value does not match")
|
ErrorUnequal(t, c.expectedJobs[i], job, "Job value does not match")
|
||||||
}
|
}
|
||||||
@ -453,6 +458,7 @@ func TestScheduleJobs(t *testing.T) {
|
|||||||
t.Logf("Cron entries: %+v", scheduledEntries)
|
t.Logf("Cron entries: %+v", scheduledEntries)
|
||||||
|
|
||||||
ErrorUnequal(t, len(c.expectedJobs), len(scheduledEntries), "Job and entry lengths don't match")
|
ErrorUnequal(t, len(c.expectedJobs), len(scheduledEntries), "Job and entry lengths don't match")
|
||||||
|
|
||||||
for i, entry := range scheduledEntries {
|
for i, entry := range scheduledEntries {
|
||||||
ErrorUnequal(t, c.expectedJobs[i], entry.Job, "Job value does not match entry")
|
ErrorUnequal(t, c.expectedJobs[i], entry.Job, "Job value does not match entry")
|
||||||
}
|
}
|
||||||
@ -659,6 +665,7 @@ func TestDoLoop(t *testing.T) {
|
|||||||
t.Logf("Cron entries: %+v", scheduledEntries)
|
t.Logf("Cron entries: %+v", scheduledEntries)
|
||||||
|
|
||||||
ErrorUnequal(t, len(c.expectedJobs), len(scheduledEntries), "Job and entry lengths don't match")
|
ErrorUnequal(t, len(c.expectedJobs), len(scheduledEntries), "Job and entry lengths don't match")
|
||||||
|
|
||||||
for i, entry := range scheduledEntries {
|
for i, entry := range scheduledEntries {
|
||||||
ErrorUnequal(t, c.expectedJobs[i], entry.Job, "Job value does not match entry")
|
ErrorUnequal(t, c.expectedJobs[i], entry.Job, "Job value does not match entry")
|
||||||
}
|
}
|
||||||
@ -890,9 +897,11 @@ func TestRunExecJobs(t *testing.T) {
|
|||||||
t.Log("Recovered from panic")
|
t.Log("Recovered from panic")
|
||||||
t.Log(err)
|
t.Log(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
c.client.AssertFakeCalls(t, c.expectedCalls, "Failed")
|
c.client.AssertFakeCalls(t, c.expectedCalls, "Failed")
|
||||||
}()
|
}()
|
||||||
job.Run()
|
job.Run()
|
||||||
|
|
||||||
if c.expectPanic {
|
if c.expectPanic {
|
||||||
t.Errorf("Expected panic but got none")
|
t.Errorf("Expected panic but got none")
|
||||||
}
|
}
|
||||||
@ -1006,9 +1015,11 @@ func TestRunStartJobs(t *testing.T) {
|
|||||||
defer func() {
|
defer func() {
|
||||||
// Recover from panics, if there were any
|
// Recover from panics, if there were any
|
||||||
_ = recover()
|
_ = recover()
|
||||||
|
|
||||||
c.client.AssertFakeCalls(t, c.expectedCalls, "Failed")
|
c.client.AssertFakeCalls(t, c.expectedCalls, "Failed")
|
||||||
}()
|
}()
|
||||||
job.Run()
|
job.Run()
|
||||||
|
|
||||||
if c.expectPanic {
|
if c.expectPanic {
|
||||||
t.Errorf("Expected panic but got none")
|
t.Errorf("Expected panic but got none")
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user