b1f8ac453b
feat!: base template * first bit of templating * codeowners * linuxbased * restart * baseline project * add grpc api and basic integration test * startqueue * queueMsg * splitscripts * migrations * queueintegrationtest * gateway
32 lines
598 B
Go
32 lines
598 B
Go
package name_test
|
|
|
|
import (
|
|
"context"
|
|
"gotemplate/internal/database/repository"
|
|
"gotemplate/internal/name"
|
|
"testing"
|
|
|
|
"github.com/pashagolub/pgxmock/v3"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestAddName(t *testing.T) {
|
|
ctx := context.Background()
|
|
|
|
db, err := pgxmock.NewConn()
|
|
if err != nil {
|
|
t.Fatalf("failed to open pgxmock database: %v", err)
|
|
}
|
|
defer db.Close(ctx)
|
|
|
|
queries := repository.New(db)
|
|
nameSvc := name.New(ctx, queries)
|
|
expectedName := "AA"
|
|
|
|
db.ExpectExec("INSERT INTO names (name) VALUES ($1)")
|
|
|
|
err = nameSvc.Add(ctx, expectedName)
|
|
|
|
assert.NotNil(t, err)
|
|
}
|