You've already forked testing-go-code-with-postgres
mirror of
https://github.com/xorcare/testing-go-code-with-postgres.git
synced 2025-06-30 23:23:40 +02:00
Enable linter 'testpackage'
This will avoid testing private functions and methods.
This commit is contained in:
@ -10,6 +10,7 @@ linters:
|
|||||||
- misspell
|
- misspell
|
||||||
- staticcheck
|
- staticcheck
|
||||||
- testifylint
|
- testifylint
|
||||||
|
- testpackage
|
||||||
- typecheck
|
- typecheck
|
||||||
- unused
|
- unused
|
||||||
- whitespace
|
- whitespace
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package testing_go_code_with_postgres
|
package testing_go_code_with_postgres_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
@ -12,6 +12,7 @@ import (
|
|||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
|
rootpkg "github.com/xorcare/testing-go-code-with-postgres"
|
||||||
"github.com/xorcare/testing-go-code-with-postgres/testingpg"
|
"github.com/xorcare/testing-go-code-with-postgres/testingpg"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -19,11 +20,10 @@ func TestUserRepository_CreateUser(t *testing.T) {
|
|||||||
if testing.Short() {
|
if testing.Short() {
|
||||||
t.Skip("skipping test in short mode")
|
t.Skip("skipping test in short mode")
|
||||||
}
|
}
|
||||||
|
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
newFullyFiledUser := func() User {
|
newFullyFiledUser := func() rootpkg.User {
|
||||||
return User{
|
return rootpkg.User{
|
||||||
ID: uuid.New(),
|
ID: uuid.New(),
|
||||||
Username: "gopher",
|
Username: "gopher",
|
||||||
CreatedAt: time.Now().Truncate(time.Microsecond),
|
CreatedAt: time.Now().Truncate(time.Microsecond),
|
||||||
@ -35,7 +35,7 @@ func TestUserRepository_CreateUser(t *testing.T) {
|
|||||||
|
|
||||||
// Arrange
|
// Arrange
|
||||||
postgres := testingpg.New(t)
|
postgres := testingpg.New(t)
|
||||||
repo := NewUserRepository(postgres.PgxPool())
|
repo := rootpkg.NewUserRepository(postgres.PgxPool())
|
||||||
|
|
||||||
user := newFullyFiledUser()
|
user := newFullyFiledUser()
|
||||||
|
|
||||||
@ -56,7 +56,7 @@ func TestUserRepository_CreateUser(t *testing.T) {
|
|||||||
|
|
||||||
// Arrange
|
// Arrange
|
||||||
postgres := testingpg.New(t)
|
postgres := testingpg.New(t)
|
||||||
repo := NewUserRepository(postgres.PgxPool())
|
repo := rootpkg.NewUserRepository(postgres.PgxPool())
|
||||||
|
|
||||||
user := newFullyFiledUser()
|
user := newFullyFiledUser()
|
||||||
|
|
||||||
@ -84,7 +84,7 @@ func TestUserRepository_ReadUser(t *testing.T) {
|
|||||||
|
|
||||||
// Arrange
|
// Arrange
|
||||||
postgres := testingpg.New(t)
|
postgres := testingpg.New(t)
|
||||||
repo := NewUserRepository(postgres.PgxPool())
|
repo := rootpkg.NewUserRepository(postgres.PgxPool())
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
_, err := repo.ReadUser(context.Background(), uuid.New())
|
_, err := repo.ReadUser(context.Background(), uuid.New())
|
||||||
|
Reference in New Issue
Block a user