6648cdf1cb
Client External ID * normalizeexternalid * cleanopenapi * cleanopenapi * changingpublic * noprecommit * testing * precommit * processtest * nodb * tests * tests
63 lines
1.5 KiB
Go
63 lines
1.5 KiB
Go
package queryservicetest_test
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
queryservicetest "queryorchestration/internal/test/queryService"
|
|
queryservicemock "queryorchestration/mocks/queryservice"
|
|
queryservice "queryorchestration/pkg/queryService"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/mock"
|
|
)
|
|
|
|
func TestCreateClientWithSync(t *testing.T) {
|
|
ctx := context.Background()
|
|
|
|
svcClient := queryservicemock.NewMockClientWithResponsesInterface(t)
|
|
|
|
svcClient.EXPECT().CreateClientWithResponse(
|
|
mock.Anything,
|
|
mock.MatchedBy(func(create queryservice.ClientCreate) bool {
|
|
return create.Name == "example_name" && create.Id == "ID"
|
|
}),
|
|
mock.Anything,
|
|
).Return(&queryservice.CreateClientResponse{
|
|
JSON201: &queryservice.ClientIDBody{
|
|
Id: "ID",
|
|
},
|
|
}, nil)
|
|
|
|
svcClient.EXPECT().UpdateClientWithResponse(
|
|
mock.Anything,
|
|
mock.MatchedBy(func(id string) bool {
|
|
return id == "ID"
|
|
}),
|
|
mock.MatchedBy(func(create queryservice.ClientUpdate) bool {
|
|
return *create.CanSync == true
|
|
}),
|
|
mock.Anything,
|
|
).Return(&queryservice.UpdateClientResponse{}, nil)
|
|
|
|
svcClient.EXPECT().GetClientWithResponse(
|
|
mock.Anything,
|
|
mock.MatchedBy(func(id string) bool {
|
|
return id == "ID"
|
|
}),
|
|
mock.Anything,
|
|
).Return(&queryservice.GetClientResponse{
|
|
JSON200: &queryservice.DocClient{
|
|
Id: "ID",
|
|
},
|
|
}, nil)
|
|
|
|
client := queryservicetest.CreateClientWithSync(t, ctx, svcClient)
|
|
|
|
assert.NotNil(t, client)
|
|
assert.NotNil(t, client)
|
|
assert.EqualExportedValues(t, queryservice.DocClient{
|
|
Id: "ID",
|
|
}, *client)
|
|
}
|