Files
tasks/.golangci.yml
Stephan BehnkeandGitHub 7a7b735f55 Revamp Update package's unit tests (1/2) (#6001)
## What changed?
<!-- Describe what has changed in this PR -->

- [x] move both stores (and their mocks) into own files
- [x] replace proto helpers with shared ones
- [x] rework Registry's Find() tests
- [x] rework Registry's HasOutgoingMessages() tests
- [x] rework Registry's FindOrCreate() tests
- [x] remove duplicate `TestStorageErrorWhenLookingUpCompletedOutcome`
(already part of `Find` tests)
- [x] remove duplicate `TestUpdateRemovalFromRegistry` (already part of
`FindOrCreate` tests)
- [x] rework Registry's Send() tests
- [x] rework Registry's RejectUnprocessed() tests
- [x] add test for Registry's FailoverVersion()
- [x] add test for Registry's NewRegistry() 
- [x] remove `TestUpdateAccepted_WorkflowCompleted` (already covered) 
- [x] add test for Registry's TryResurrect()

## Why?
<!-- Tell your future self why have you made these changes -->

To make sure the update package tests are in tip top shape.

## How did you test it?
<!-- How have you verified this change? Tested locally? Added a unit
test? Checked in staging env? -->

All tests (and production code changes are purely cosmetic).

## Potential risks
<!-- Assuming the worst case, what can be broken when deploying this
change to production? -->

## Documentation
<!-- Have you made sure this change doesn't falsify anything currently
stated in `docs/`? If significant
new behavior is added, have you described that in `docs/`? -->

## Is hotfix candidate?
<!-- Is this PR a hotfix candidate or does it require a notification to
be sent to the broader community? (Yes/No) -->
2024-05-28 20:27:00 +00:00

130 lines
3.3 KiB
YAML

# https://golangci-lint.run/usage/configuration/#config-file
linters:
disable-all: true
enable:
- goerr113
- errcheck
- goimports
# - paralleltest # missing the call to method parallel, but testify does not seem to work well with parallel test: https://github.com/stretchr/testify/issues/187
- revive # revive supersedes golint, which is now archived
- staticcheck
- vet
- forbidigo
- exhaustive
- godox
linters-settings:
godox:
keywords:
- FIXME # marks TODOs that must be fixed before merging
govet:
fieldalignment: 0
forbidigo:
forbid:
- p: time.Sleep
msg: "Please use require.Eventually or assert.Eventually instead unless you've no other option"
- p: ^time\.After$
msg: "time.After may leak resources. Use time.NewTimer instead."
revive:
severity: error
confidence: 0.8
enable-all-rules: true
rules:
# Disabled rules
- name: add-constant
disabled: true
- name: argument-limit
disabled: true
- name: bare-return
disabled: true
- name: banned-characters
disabled: true
- name: bool-literal-in-expr
disabled: true
- name: confusing-naming
disabled: true
- name: empty-lines
disabled: true
- name: error-naming
disabled: true
- name: errorf
disabled: true
- name: exported
disabled: true
- name: file-header
disabled: true
- name: function-length
disabled: true
- name: imports-blacklist
disabled: true
- name: increment-decrement
disabled: true
- name: line-length-limit
disabled: true
- name: max-public-structs
disabled: true
- name: nested-structs
disabled: true
- name: package-comments
disabled: true
- name: string-format
disabled: true
- name: unexported-naming
disabled: true
- name: unexported-return
disabled: true
- name: unused-parameter
disabled: true
- name: unused-receiver
disabled: true
- name: use-any
disabled: true
- name: var-naming
disabled: true
- name: empty-block
disabled: true
- name: flag-parameter
disabled: true
- name: unnecessary-stmt
disabled: true
# Rule tuning
- name: cognitive-complexity
arguments:
- 25
- name: cyclomatic
arguments:
- 25
- name: function-result-limit
arguments:
- 5
- name: unhandled-error
arguments:
- "fmt.*"
- "bytes.Buffer.*"
- "strings.Builder.*"
issues:
exclude-dirs:
- ^api
- ^proto
- ^.git
exclude-rules:
- path-except: _test\.go|tests/.+\.go
text: "time.Sleep"
linters:
- forbidigo
- path: _test\.go|tests/.+\.go
text: "(cyclomatic|cognitive)" # false positives when using subtests
linters:
- revive
- path: _test\.go|tests/.+\.go
text: "dot-imports" # helpful in tests
linters:
- revive
- path: _test\.go|tests/.+\.go
linters:
- goerr113 # like err = errors.New("test error")
- path: ^tools\/.+\.go
linters:
- goerr113
- revive