@@ -3,7 +3,6 @@ package client
|
||||
import (
|
||||
"context"
|
||||
|
||||
"queryorchestration/internal/collector"
|
||||
"queryorchestration/internal/database"
|
||||
|
||||
"github.com/google/uuid"
|
||||
@@ -20,12 +19,5 @@ func (s *Service) Create(ctx context.Context, name string) (uuid.UUID, error) {
|
||||
return uuid.Nil, err
|
||||
}
|
||||
|
||||
err = s.svc.Collector.Create(ctx, &collector.CreateParams{
|
||||
ClientID: database.MustToUUID(id),
|
||||
})
|
||||
if err != nil {
|
||||
return uuid.Nil, err
|
||||
}
|
||||
|
||||
return database.MustToUUID(id), nil
|
||||
}
|
||||
|
||||
@@ -5,15 +5,11 @@ import (
|
||||
"testing"
|
||||
|
||||
"queryorchestration/internal/client"
|
||||
"queryorchestration/internal/collector"
|
||||
"queryorchestration/internal/database"
|
||||
"queryorchestration/internal/database/repository"
|
||||
cleanversion "queryorchestration/internal/document/clean/version"
|
||||
textversion "queryorchestration/internal/document/text/version"
|
||||
"queryorchestration/internal/serviceconfig"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/jackc/pgx/v5"
|
||||
"github.com/pashagolub/pgxmock/v3"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
@@ -28,12 +24,7 @@ func TestCreate(t *testing.T) {
|
||||
cfg.DBPool = pool
|
||||
cfg.DBQueries = repository.New(pool)
|
||||
|
||||
svc := client.New(cfg, &client.Services{
|
||||
Collector: collector.New(cfg, &collector.Services{
|
||||
CleanVersion: cleanversion.New(cfg),
|
||||
TextVersion: textversion.New(cfg),
|
||||
}),
|
||||
})
|
||||
svc := client.New(cfg)
|
||||
|
||||
name := "client_name"
|
||||
aid := uuid.New()
|
||||
@@ -43,14 +34,6 @@ func TestCreate(t *testing.T) {
|
||||
pgxmock.NewRows([]string{"id"}).
|
||||
AddRow(database.MustToDBUUID(aid)),
|
||||
)
|
||||
pool.ExpectBeginTx(pgx.TxOptions{})
|
||||
pool.ExpectQuery("name: AddLatestCollectorVersion :one").WithArgs(database.MustToDBUUID(aid)).WillReturnRows(
|
||||
pgxmock.NewRows([]string{"version"}).
|
||||
AddRow(int32(1)),
|
||||
)
|
||||
pool.ExpectExec("name: SetActiveCollectorVersion :exec").WithArgs(database.MustToDBUUID(aid), int32(1)).
|
||||
WillReturnResult(pgxmock.NewResult("", 1))
|
||||
pool.ExpectCommit()
|
||||
|
||||
id, err := svc.Create(ctx, name)
|
||||
assert.NoError(t, err)
|
||||
|
||||
@@ -25,7 +25,7 @@ func TestGet(t *testing.T) {
|
||||
cfg.DBPool = pool
|
||||
cfg.DBQueries = repository.New(pool)
|
||||
|
||||
svc := client.New(cfg, &client.Services{})
|
||||
svc := client.New(cfg)
|
||||
|
||||
id := uuid.New()
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ import (
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"queryorchestration/internal/collector"
|
||||
"queryorchestration/internal/serviceconfig"
|
||||
|
||||
"github.com/google/uuid"
|
||||
@@ -71,18 +70,12 @@ func normalizeName(name *string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
type Services struct {
|
||||
Collector *collector.Service
|
||||
}
|
||||
|
||||
type Service struct {
|
||||
cfg serviceconfig.ConfigProvider
|
||||
svc *Services
|
||||
}
|
||||
|
||||
func New(cfg serviceconfig.ConfigProvider, svc *Services) *Service {
|
||||
func New(cfg serviceconfig.ConfigProvider) *Service {
|
||||
return &Service{
|
||||
cfg,
|
||||
svc,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,6 @@ func TestService(t *testing.T) {
|
||||
cfg.DBPool = pool
|
||||
cfg.DBQueries = repository.New(pool)
|
||||
|
||||
svc := client.New(cfg, &client.Services{})
|
||||
svc := client.New(cfg)
|
||||
assert.NotNil(t, svc)
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ func TestGetStatus(t *testing.T) {
|
||||
cfg.DBPool = pool
|
||||
cfg.DBQueries = repository.New(pool)
|
||||
|
||||
svc := client.New(cfg, &client.Services{})
|
||||
svc := client.New(cfg)
|
||||
|
||||
clientId := uuid.New()
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ func TestUpdate(t *testing.T) {
|
||||
cfg.DBPool = pool
|
||||
cfg.DBQueries = repository.New(pool)
|
||||
|
||||
svc := New(cfg, &Services{})
|
||||
svc := New(cfg)
|
||||
|
||||
c := Client{
|
||||
ID: uuid.New(),
|
||||
@@ -120,7 +120,7 @@ func TestSubmitUpdate(t *testing.T) {
|
||||
cfg.DBPool = pool
|
||||
cfg.DBQueries = repository.New(pool)
|
||||
|
||||
svc := New(cfg, &Services{})
|
||||
svc := New(cfg)
|
||||
|
||||
c := Client{
|
||||
ID: uuid.New(),
|
||||
|
||||
Reference in New Issue
Block a user