Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

finish moving last of json testdata to use BestTestClient #309

Merged
merged 4 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,026 changes: 604 additions & 422 deletions check_test.go

Large diffs are not rendered by default.

18 changes: 0 additions & 18 deletions clientGQL_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,6 @@ func ABetterTestClient(t *testing.T, endpoint string, request string, response s
GraphQLQueryTemplatedValidation(t, request))))
}

func ATestClient(t *testing.T, endpoint string) *ol.Client {
return ol.NewGQLClient(ol.SetAPIToken("x"), ol.SetMaxRetries(0), ol.SetURL(autopilot.RegisterEndpoint(fmt.Sprintf("/LOCAL_TESTING/%s", endpoint),
autopilot.FixtureResponse(fmt.Sprintf("%s_response.json", endpoint)),
autopilot.GraphQLQueryFixtureValidation(t, fmt.Sprintf("%s_request.json", endpoint)))))
}

func NewTestRequest(request string, variables string, response string) TestRequest {
testRequest := TestRequest{
Request: Templated(request),
Expand Down Expand Up @@ -184,18 +178,6 @@ func BestTestClient(t *testing.T, endpoint string, requests ...TestRequest) *ol.
return ol.NewGQLClient(ol.SetAPIToken("x"), ol.SetMaxRetries(0), ol.SetURL(url))
}

func ATestClientAlt(t *testing.T, response string, request string) *ol.Client {
return ol.NewGQLClient(ol.SetAPIToken("x"), ol.SetMaxRetries(0), ol.SetURL(autopilot.RegisterEndpoint(fmt.Sprintf("/LOCAL_TESTING/%s__%s", response, request),
autopilot.FixtureResponse(fmt.Sprintf("%s_response.json", response)),
autopilot.GraphQLQueryFixtureValidation(t, fmt.Sprintf("%s_request.json", request)))))
}

func ATestClientSkipRequest(t *testing.T, endpoint string) *ol.Client {
return ol.NewGQLClient(ol.SetAPIToken("x"), ol.SetMaxRetries(0), ol.SetURL(autopilot.RegisterEndpoint(fmt.Sprintf("/LOCAL_TESTING/%s", endpoint),
autopilot.FixtureResponse(fmt.Sprintf("%s_response.json", endpoint)),
autopilot.SkipRequestValidation())))
}

func TestClientQuery(t *testing.T) {
// Arrange
headers := map[string]string{"x": "x"}
Expand Down
13 changes: 12 additions & 1 deletion clientRest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,29 @@ package opslevel_test

import (
"fmt"
"net/http"
"testing"

"github.com/go-resty/resty/v2"
ol "github.com/opslevel/opslevel-go/v2023"
"github.com/rocktavious/autopilot/v2023"
)

const testRestClientResponse = `{ "result": "Hello World!" }`

func testRestClientResponseWriter() autopilot.ResponseWriter {
return func(w http.ResponseWriter) {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
fmt.Fprint(w, testRestClientResponse)
}
}

func ATestRestClient(t *testing.T, endpoint string) *resty.Client {
return ol.NewRestClient(ol.SetURL(
autopilot.RegisterEndpoint(
fmt.Sprintf("/%s", endpoint),
autopilot.FixtureResponse(fmt.Sprintf("%s_response.json", endpoint)),
testRestClientResponseWriter(),
autopilot.SkipRequestValidation(),
),
),
Expand Down
14 changes: 0 additions & 14 deletions testdata/fixtures/check/create_alert_source_usage_request.json

This file was deleted.

25 changes: 0 additions & 25 deletions testdata/fixtures/check/create_alert_source_usage_response.json

This file was deleted.

17 changes: 0 additions & 17 deletions testdata/fixtures/check/create_custom_event_request.json

This file was deleted.

25 changes: 0 additions & 25 deletions testdata/fixtures/check/create_custom_event_response.json

This file was deleted.

12 changes: 0 additions & 12 deletions testdata/fixtures/check/create_git_branch_protection_request.json

This file was deleted.

26 changes: 0 additions & 26 deletions testdata/fixtures/check/create_git_branch_protection_response.json

This file was deleted.

14 changes: 0 additions & 14 deletions testdata/fixtures/check/create_has_documentation_request.json

This file was deleted.

29 changes: 0 additions & 29 deletions testdata/fixtures/check/create_has_documentation_response.json

This file was deleted.

13 changes: 0 additions & 13 deletions testdata/fixtures/check/create_has_recent_deploy_request.json

This file was deleted.

26 changes: 0 additions & 26 deletions testdata/fixtures/check/create_has_recent_deploy_response.json

This file was deleted.

18 changes: 0 additions & 18 deletions testdata/fixtures/check/create_manual_request.json

This file was deleted.

26 changes: 0 additions & 26 deletions testdata/fixtures/check/create_manual_response.json

This file was deleted.

Loading
Loading