51 lines
1.3 KiB
Go
51 lines
1.3 KiB
Go
|
|
package integration_test
|
||
|
|
|
||
|
|
import (
|
||
|
|
"context"
|
||
|
|
"queryorchestration/internal/test"
|
||
|
|
queryservice "queryorchestration/pkg/queryService"
|
||
|
|
"testing"
|
||
|
|
|
||
|
|
"github.com/stretchr/testify/assert"
|
||
|
|
)
|
||
|
|
|
||
|
|
func TestClient(t *testing.T) {
|
||
|
|
ctx := context.Background()
|
||
|
|
|
||
|
|
address, cleanup := test.CreateAPIWithDependencies(t, ctx, "queryService")
|
||
|
|
defer cleanup()
|
||
|
|
|
||
|
|
client, err := queryservice.NewClientWithResponses(address)
|
||
|
|
assert.Nil(t, err)
|
||
|
|
|
||
|
|
idRes, err := client.CreateClientWithResponse(ctx, queryservice.ClientCreate{
|
||
|
|
Name: "example_name",
|
||
|
|
})
|
||
|
|
assert.Nil(t, err)
|
||
|
|
assert.NotNil(t, idRes)
|
||
|
|
assert.NotNil(t, idRes.JSON201)
|
||
|
|
assert.NotNil(t, idRes.JSON201.Id)
|
||
|
|
id := idRes.JSON201.Id
|
||
|
|
|
||
|
|
clientRes, err := client.GetClientWithResponse(ctx, id)
|
||
|
|
assert.Nil(t, err)
|
||
|
|
assert.Equal(t, id, clientRes.JSON200.Id)
|
||
|
|
assert.Equal(t, "example_name", clientRes.JSON200.Name)
|
||
|
|
assert.False(t, clientRes.JSON200.CanSync)
|
||
|
|
|
||
|
|
updateName := "update_name"
|
||
|
|
updateCanSync := true
|
||
|
|
updateRes, err := client.UpdateClientWithResponse(ctx, id, queryservice.ClientUpdate{
|
||
|
|
Name: &updateName,
|
||
|
|
CanSync: &updateCanSync,
|
||
|
|
})
|
||
|
|
assert.Nil(t, err)
|
||
|
|
assert.NotNil(t, updateRes)
|
||
|
|
|
||
|
|
clientRes, err = client.GetClientWithResponse(ctx, id)
|
||
|
|
assert.Nil(t, err)
|
||
|
|
assert.Equal(t, id, clientRes.JSON200.Id)
|
||
|
|
assert.Equal(t, updateName, clientRes.JSON200.Name)
|
||
|
|
assert.True(t, clientRes.JSON200.CanSync)
|
||
|
|
}
|