Skip to content

Commit

Permalink
enable thelper
Browse files Browse the repository at this point in the history
  • Loading branch information
faddat committed Aug 14, 2023
1 parent d6f86cc commit 9fdf576
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ linters:
- misspell
- prealloc
- staticcheck
- thelper
- typecheck
- unconvert
- unused
Expand All @@ -51,7 +52,6 @@ linters:
# - godot
# - godox
# - goerr113
# - gofumpt
# - goheader
# - golint
# - gomnd
Expand Down
6 changes: 6 additions & 0 deletions caddytest/caddytest.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ type Tester struct {

// NewTester will create a new testing client with an attached cookie jar
func NewTester(t *testing.T) *Tester {
t.Helper()
jar, err := cookiejar.New(nil)
if err != nil {
t.Fatalf("failed to create cookiejar: %s", err)
Expand Down Expand Up @@ -230,6 +231,7 @@ const initConfig = `{
// validateTestPrerequisites ensures the certificates are available in the
// designated path and Caddy sub-process is running.
func validateTestPrerequisites(t *testing.T) error {
t.Helper()
// check certificates are found
for _, certName := range Default.Certifcates {
if _, err := os.Stat(getIntegrationDir() + certName); os.IsNotExist(err) {
Expand Down Expand Up @@ -327,6 +329,7 @@ func CreateTestingTransport() *http.Transport {

// AssertLoadError will load a config and expect an error
func AssertLoadError(t *testing.T, rawConfig string, configType string, expectedError string) {
t.Helper()
tc := NewTester(t)

err := tc.initServer(rawConfig, configType)
Expand Down Expand Up @@ -374,6 +377,7 @@ func (tc *Tester) AssertRedirect(requestURI string, expectedToLocation string, e

// CompareAdapt adapts a config and then compares it against an expected result
func CompareAdapt(t *testing.T, filename, rawConfig string, adapterName string, expectedResponse string) bool {
t.Helper()
cfgAdapter := caddyconfig.GetAdapter(adapterName)
if cfgAdapter == nil {
t.Logf("unrecognized config adapter '%s'", adapterName)
Expand Down Expand Up @@ -433,6 +437,7 @@ func CompareAdapt(t *testing.T, filename, rawConfig string, adapterName string,

// AssertAdapt adapts a config and then tests it against an expected result
func AssertAdapt(t *testing.T, rawConfig string, adapterName string, expectedResponse string) {
t.Helper()
ok := CompareAdapt(t, "Caddyfile", rawConfig, adapterName, expectedResponse)
if !ok {
t.Fail()
Expand All @@ -442,6 +447,7 @@ func AssertAdapt(t *testing.T, rawConfig string, adapterName string, expectedRes
// Generic request functions

func applyHeaders(t *testing.T, req *http.Request, requestHeaders []string) {
t.Helper()
requestContentType := ""
for _, requestHeader := range requestHeaders {
arr := strings.SplitAfterN(requestHeader, ":", 2)
Expand Down

0 comments on commit 9fdf576

Please sign in to comment.