mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
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:
@@ -241,6 +241,7 @@ linters:
|
||||
- staticcheck
|
||||
- structcheck
|
||||
- tenv
|
||||
- testpackage
|
||||
- tparallel
|
||||
- typecheck
|
||||
- unconvert
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
|
||||
+4
-2
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user