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.
This commit is contained in:
Kyle Carberry 2022-02-04 12:06:06 -06:00 committed by GitHub
parent b6d27adba0
commit 75468fad48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 6 deletions

View File

@ -241,6 +241,7 @@ linters:
- staticcheck
- structcheck
- tenv
- testpackage
- tparallel
- typecheck
- unconvert

View File

@ -1,6 +1,6 @@
//go:build linux
package terraform
package terraform_test
import (
"context"
@ -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"
)
@ -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,
},

View File

@ -1,6 +1,6 @@
//go:build linux
package terraform
package terraform_test
import (
"context"
@ -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"
)
@ -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,
},

View File

@ -1,4 +1,4 @@
package site
package site_test
import (
"context"
@ -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)