Skip to content

Commit

Permalink
Merge pull request #309 from OpsLevel/db/update-table-tested-checks
Browse files Browse the repository at this point in the history
finish moving last of json testdata to use BestTestClient
  • Loading branch information
davidbloss authored Nov 15, 2023
2 parents 6e22c7d + 27b8041 commit 6259036
Show file tree
Hide file tree
Showing 78 changed files with 616 additions and 1,915 deletions.
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

0 comments on commit 6259036

Please sign in to comment.