Skip to content

Commit 75468fa

Browse files
authored
chore: Add testpackage linter (#156)
Enforces a consistent test package layout. This makes it difficult to test internal functionality, which I believe promotes healthy decomposition, and minimal package exports.
1 parent b6d27ad commit 75468fa

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

.golangci.yml

+1
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ linters:
241241
- staticcheck
242242
- structcheck
243243
- tenv
244+
- testpackage
244245
- tparallel
245246
- typecheck
246247
- unconvert

provisioner/terraform/parse_test.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//go:build linux
22

3-
package terraform
3+
package terraform_test
44

55
import (
66
"context"
@@ -11,6 +11,7 @@ import (
1111

1212
"github.com/stretchr/testify/require"
1313

14+
"github.com/coder/coder/provisioner/terraform"
1415
"github.com/coder/coder/provisionersdk"
1516
"github.com/coder/coder/provisionersdk/proto"
1617
)
@@ -27,7 +28,7 @@ func TestParse(t *testing.T) {
2728
cancelFunc()
2829
})
2930
go func() {
30-
err := Serve(ctx, &ServeOptions{
31+
err := terraform.Serve(ctx, &terraform.ServeOptions{
3132
ServeOptions: &provisionersdk.ServeOptions{
3233
Listener: server,
3334
},

provisioner/terraform/provision_test.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//go:build linux
22

3-
package terraform
3+
package terraform_test
44

55
import (
66
"context"
@@ -11,6 +11,7 @@ import (
1111

1212
"github.com/stretchr/testify/require"
1313

14+
"github.com/coder/coder/provisioner/terraform"
1415
"github.com/coder/coder/provisionersdk"
1516
"github.com/coder/coder/provisionersdk/proto"
1617
)
@@ -26,7 +27,7 @@ func TestProvision(t *testing.T) {
2627
cancelFunc()
2728
})
2829
go func() {
29-
err := Serve(ctx, &ServeOptions{
30+
err := terraform.Serve(ctx, &terraform.ServeOptions{
3031
ServeOptions: &provisionersdk.ServeOptions{
3132
Listener: server,
3233
},

site/embed_test.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package site
1+
package site_test
22

33
import (
44
"context"
@@ -8,12 +8,14 @@ import (
88
"testing"
99

1010
"github.com/stretchr/testify/require"
11+
12+
"github.com/coder/coder/site"
1113
)
1214

1315
func TestIndexPageRenders(t *testing.T) {
1416
t.Parallel()
1517

16-
srv := httptest.NewServer(Handler())
18+
srv := httptest.NewServer(site.Handler())
1719

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

0 commit comments

Comments
 (0)