Skip to content

Commit

Permalink
chore: Add testpackage linter (#156)
Browse files Browse the repository at this point in the history
Enforces a consistent test package layout.
This makes it difficult to test internal
functionality, which I believe promotes
healthy decomposition, and minimal package
exports.
  • Loading branch information
kylecarbs committed Feb 4, 2022
1 parent b6d27ad commit 75468fa
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ linters:
- staticcheck
- structcheck
- tenv
- testpackage
- tparallel
- typecheck
- unconvert
Expand Down
5 changes: 3 additions & 2 deletions provisioner/terraform/parse_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//go:build linux

package terraform
package terraform_test

import (
"context"
Expand All @@ -11,6 +11,7 @@ import (

"github.com/stretchr/testify/require"

"github.com/coder/coder/provisioner/terraform"
"github.com/coder/coder/provisionersdk"
"github.com/coder/coder/provisionersdk/proto"
)
Expand All @@ -27,7 +28,7 @@ func TestParse(t *testing.T) {
cancelFunc()
})
go func() {
err := Serve(ctx, &ServeOptions{
err := terraform.Serve(ctx, &terraform.ServeOptions{
ServeOptions: &provisionersdk.ServeOptions{
Listener: server,
},
Expand Down
5 changes: 3 additions & 2 deletions provisioner/terraform/provision_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//go:build linux

package terraform
package terraform_test

import (
"context"
Expand All @@ -11,6 +11,7 @@ import (

"github.com/stretchr/testify/require"

"github.com/coder/coder/provisioner/terraform"
"github.com/coder/coder/provisionersdk"
"github.com/coder/coder/provisionersdk/proto"
)
Expand All @@ -26,7 +27,7 @@ func TestProvision(t *testing.T) {
cancelFunc()
})
go func() {
err := Serve(ctx, &ServeOptions{
err := terraform.Serve(ctx, &terraform.ServeOptions{
ServeOptions: &provisionersdk.ServeOptions{
Listener: server,
},
Expand Down
6 changes: 4 additions & 2 deletions site/embed_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package site
package site_test

import (
"context"
Expand All @@ -8,12 +8,14 @@ import (
"testing"

"github.com/stretchr/testify/require"

"github.com/coder/coder/site"
)

func TestIndexPageRenders(t *testing.T) {
t.Parallel()

srv := httptest.NewServer(Handler())
srv := httptest.NewServer(site.Handler())

req, err := http.NewRequestWithContext(context.Background(), "GET", srv.URL, nil)
require.NoError(t, err)
Expand Down

0 comments on commit 75468fa

Please sign in to comment.