## Summary: We have lots of tests covering codegen, but not a lot that actually run the code. For things where all we do is generate types, that's (mostly) fine (especially now that we actually build the code), but as we generate more nontrivial non-type code we need to actually run it. So I wrote some integration tests that spin up a little gqlgen server, and make calls to it; we can add more over time especially as the JSON marshalling logic gets complex (to support fragments). They're more work to write than the snapshot tests, but of course they can test a lot more. In addition to gqlgen, I pulled in testify assert/require, because I really wanted to be able to use assert.Equal and such for these. I didn't bother converting existing tests, although I assume they will become useful elsewhere in time. Both gqlgen and testify are of course only used in tests. Fixes #21 and #24. Issue: https://github.com/Khan/genqlient/issues/21 Issue: https://github.com/Khan/genqlient/issues/24 ## Test plan: make check Author: benjaminjkraft Reviewers: aberkan, dnerdy, benjaminjkraft, csilvers, MiguelCastillo Required Reviewers: Approved by: aberkan, dnerdy Checks: ✅ Test (1.17), ✅ Test (1.16), ✅ Test (1.15), ✅ Test (1.14), ✅ Test (1.13), ✅ Lint, ✅ Test (1.17), ✅ Test (1.16), ✅ Test (1.15), ✅ Test (1.14), ✅ Test (1.13), ✅ Lint Pull request URL: https://github.com/Khan/genqlient/pull/50
103 lines
2.5 KiB
YAML
103 lines
2.5 KiB
YAML
# For the full list of configuration options, see
|
|
# https://github.com/golangci/golangci-lint#config-file
|
|
|
|
# See more about these linters at https://golangci-lint.run/usage/linters/
|
|
linters:
|
|
fast: false
|
|
disable-all: true
|
|
enable:
|
|
# golangci enables these by default.
|
|
- deadcode
|
|
- errcheck
|
|
- gofumpt # (replaces gofmt)
|
|
- gosimple
|
|
- govet
|
|
- ineffassign
|
|
- staticcheck
|
|
- structcheck
|
|
- typecheck
|
|
- unused
|
|
- varcheck
|
|
# golangci disables these by default, but we use them.
|
|
- bodyclose
|
|
- depguard
|
|
- durationcheck
|
|
- errorlint
|
|
- exportloopref
|
|
- gocritic
|
|
- nakedret
|
|
- stylecheck
|
|
- unconvert
|
|
- unparam
|
|
- whitespace
|
|
|
|
linters-settings:
|
|
errcheck:
|
|
check-type-assertions: true # check for a := b.(T)
|
|
|
|
errorlint:
|
|
errorf: false # it's valid to use %v instead of %w
|
|
|
|
govet:
|
|
check-shadowing: true
|
|
enable-all: true
|
|
|
|
# We have a ton of test-only packages; but make sure we keep prod deps small.
|
|
depguard:
|
|
list-type: whitelist
|
|
packages:
|
|
- github.com/Khan/genqlient
|
|
- github.com/vektah/gqlparser/v2
|
|
- golang.org/x/tools
|
|
- gopkg.in/yaml.v2
|
|
|
|
gocritic:
|
|
# Which checks should be enabled:
|
|
# See https://go-critic.github.io/overview#checks-overview
|
|
# and https://github.com/go-critic/go-critic#usage -> section "Tags".
|
|
# To check which checks are enabled: `GL_DEBUG=gocritic golangci-lint run`
|
|
enabled-tags:
|
|
- diagnostic
|
|
- performance
|
|
- style
|
|
|
|
disabled-checks:
|
|
- builtinShadow
|
|
- commentedOutCode
|
|
- importShadow
|
|
- paramTypeCombine
|
|
- unnamedResult
|
|
- ifElseChain
|
|
- sloppyReassign
|
|
- typeDefFirst
|
|
|
|
settings: # settings passed to gocritic
|
|
captLocal: # must be valid enabled check name
|
|
paramsOnly: true
|
|
|
|
|
|
issues:
|
|
exclude-rules:
|
|
# Test-only deps are not restricted.
|
|
- linters:
|
|
- depguard
|
|
path: _test\.go$|internal/testutil/|internal/integration/
|
|
|
|
- linters:
|
|
- errcheck
|
|
path: _test\.go$
|
|
# Unchecked type-asserts are ok in tests -- a panic will be plenty clear.
|
|
# An error message with no function name means an unchecked type-assert.
|
|
text: "^Error return value is not checked$"
|
|
|
|
# Don't error if a test setup function always takes the same arguments.
|
|
- linters:
|
|
- unparam
|
|
path: _test\.go$
|
|
|
|
- linters:
|
|
- govet
|
|
# Only a big deal for runtime code.
|
|
path: ^generate/|^example/
|
|
text: "^fieldalignment: struct with \\d+ pointer bytes could be \\d+$"
|