Skip to content

Commit

Permalink
use dedicated settings struct
Browse files Browse the repository at this point in the history
  • Loading branch information
broswen committed Sep 14, 2023
1 parent 6283e8f commit 307ddb4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
13 changes: 6 additions & 7 deletions observatory.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,11 @@ func (api *API) ListObservatoryPageTests(ctx context.Context, rc *ResourceContai
}

type CreateObservatoryPageTestParams struct {
URL string
Region string
URL string
Settings CreateObservatoryPageTestSettings
}
type CreateObservatoryPageTestSettings struct {
Region string `json:"region"`
}

type ObservatoryPageTestResponse struct {
Expand All @@ -221,11 +224,7 @@ func (api *API) CreateObservatoryPageTest(ctx context.Context, rc *ResourceConta
return nil, ErrMissingObservatoryUrl
}
uri := fmt.Sprintf("/zones/%s/speed_api/pages/%s/tests", rc.Identifier, url.PathEscape(params.URL))
res, err := api.makeRequestContext(ctx, http.MethodPost, uri, struct {
Region string `json:"region"`
}{
Region: params.Region,
})
res, err := api.makeRequestContext(ctx, http.MethodPost, uri, params.Settings)
if err != nil {
return nil, err
}
Expand Down
6 changes: 4 additions & 2 deletions observatory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,10 @@ func TestCreateObservatoryPageTest(t *testing.T) {
mux.HandleFunc("/zones/"+testZoneID+"/speed_api/pages/"+testURL+"/tests", handler)
want := pageTest
test, err := client.CreateObservatoryPageTest(context.Background(), ZoneIdentifier(testZoneID), CreateObservatoryPageTestParams{
URL: testURL,
Region: region,
URL: testURL,
Settings: CreateObservatoryPageTestSettings{
Region: region,
},
})
if assert.NoError(t, err) {
assert.Equal(t, &want, test)
Expand Down

0 comments on commit 307ddb4

Please sign in to comment.