Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
vmanilo committed Jan 27, 2024
1 parent 4eeee0e commit 1ab1b20
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
16 changes: 8 additions & 8 deletions twingate/internal/test/client/connector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ func TestClientConnectorReadEmptyError(t *testing.T) {
httpmock.RegisterResponder("POST", client.GraphqlServerURL,
httpmock.NewStringResponder(200, emptyResponse))

connectors, err := client.ReadConnectors(context.Background())
connectors, err := client.ReadConnectors(context.Background(), "", "")

assert.Empty(t, connectors)
assert.EqualError(t, err, "failed to read connector with id All: query result is empty")
Expand Down Expand Up @@ -603,7 +603,7 @@ func TestClientConnectorReadAllOk(t *testing.T) {
httpmock.RegisterResponder("POST", client.GraphqlServerURL,
httpmock.NewStringResponder(200, jsonResponse))

connectors, err := client.ReadConnectors(context.Background())
connectors, err := client.ReadConnectors(context.Background(), "", "")
assert.NoError(t, err)
assert.Equal(t, expected, connectors)
})
Expand Down Expand Up @@ -769,7 +769,7 @@ func TestClientReadConnectorsWithRemoteNetworkOk(t *testing.T) {
httpmock.RegisterResponder("POST", client.GraphqlServerURL,
httpmock.NewStringResponder(200, jsonResponse))

connectors, err := client.ReadConnectors(context.Background())
connectors, err := client.ReadConnectors(context.Background(), "", "")

assert.NoError(t, err)
assert.Equal(t, expected, connectors)
Expand All @@ -789,7 +789,7 @@ func TestClientReadConnectorsWithRemoteNetworkError(t *testing.T) {
httpmock.RegisterResponder("POST", client.GraphqlServerURL,
httpmock.NewStringResponder(200, jsonResponse))

connectors, err := client.ReadConnectors(context.Background())
connectors, err := client.ReadConnectors(context.Background(), "", "")

assert.Nil(t, connectors)
assert.EqualError(t, err, "failed to read connector with id All: query result is empty")
Expand All @@ -803,7 +803,7 @@ func TestClientReadConnectorsWithRemoteNetworkRequestError(t *testing.T) {
httpmock.RegisterResponder("POST", client.GraphqlServerURL,
httpmock.NewErrorResponder(errBadRequest))

connectors, err := client.ReadConnectors(context.Background())
connectors, err := client.ReadConnectors(context.Background(), "", "")

assert.Nil(t, connectors)
assert.EqualError(t, err, graphqlErr(client, "failed to read connector with id All", errBadRequest))
Expand Down Expand Up @@ -883,7 +883,7 @@ func TestClientReadConnectorsAllPagesOk(t *testing.T) {
}),
)

connectors, err := client.ReadConnectors(context.Background())
connectors, err := client.ReadConnectors(context.Background(), "", "")
assert.NoError(t, err)
assert.Equal(t, expected, connectors)
})
Expand Down Expand Up @@ -933,7 +933,7 @@ func TestClientReadConnectorsAllPagesEmptyResultOnFetching(t *testing.T) {
),
)

connectors, err := client.ReadConnectors(context.Background())
connectors, err := client.ReadConnectors(context.Background(), "", "")
assert.Nil(t, connectors)
assert.EqualError(t, err, `failed to read connector with id All: query result is empty`)
})
Expand Down Expand Up @@ -972,7 +972,7 @@ func TestClientReadConnectorsAllPagesRequestErrorOnFetching(t *testing.T) {
),
)

connectors, err := client.ReadConnectors(context.Background())
connectors, err := client.ReadConnectors(context.Background(), "", "")
assert.Nil(t, connectors)
assert.EqualError(t, err, graphqlErr(client, "failed to read connector with id All", errBadRequest))
})
Expand Down
4 changes: 3 additions & 1 deletion twingate/internal/test/sweepers/connector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package sweepers
import (
"context"
"errors"
"github.com/Twingate/terraform-provider-twingate/twingate/internal/attr"
"github.com/Twingate/terraform-provider-twingate/twingate/internal/test"

"github.com/Twingate/terraform-provider-twingate/twingate/internal/client"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
Expand All @@ -15,7 +17,7 @@ func init() {
Name: resourceConnector,
F: newTestSweeper(resourceConnector,
func(c *client.Client, ctx context.Context) ([]Resource, error) {
resources, err := c.ReadConnectors(ctx)
resources, err := c.ReadConnectors(ctx, test.Prefix(), attr.FilterByPrefix)
if err != nil && !errors.Is(err, client.ErrGraphqlResultIsEmpty) {
return nil, err
}
Expand Down

0 comments on commit 1ab1b20

Please sign in to comment.