Skip to content

Commit

Permalink
Revert "test(mux): handle url encoding in definitions"
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobbednarz authored Nov 25, 2024
1 parent 70d1ded commit 89eab58
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 21 deletions.
18 changes: 9 additions & 9 deletions observatory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ func TestObservatoryPageTrend(t *testing.T) {
}
`)
}
mux.HandleFunc("/zones/"+testZoneID+"/speed_api/pages/"+escapedTestURL+"/trend", handler)
mux.HandleFunc("/zones/"+testZoneID+"/speed_api/pages/"+testURL+"/trend", handler)
want := ObservatoryPageTrend{
PerformanceScore: []*int{nil, IntPtr(100)},
TTFB: []*int{nil, IntPtr(10)},
Expand Down Expand Up @@ -268,7 +268,7 @@ func TestListObservatoryPageTests(t *testing.T) {
}
`, pageTestJSON)
}
mux.HandleFunc("/zones/"+testZoneID+"/speed_api/pages/"+escapedTestURL+"/tests", handler)
mux.HandleFunc("/zones/"+testZoneID+"/speed_api/pages/"+testURL+"/tests", handler)
want := []ObservatoryPageTest{
pageTest,
}
Expand Down Expand Up @@ -304,7 +304,7 @@ func TestCreateObservatoryPageTest(t *testing.T) {
}
`, pageTestJSON)
}
mux.HandleFunc("/zones/"+testZoneID+"/speed_api/pages/"+escapedTestURL+"/tests", handler)
mux.HandleFunc("/zones/"+testZoneID+"/speed_api/pages/"+testURL+"/tests", handler)
want := pageTest
test, err := client.CreateObservatoryPageTest(context.Background(), ZoneIdentifier(testZoneID), CreateObservatoryPageTestParams{
URL: testURL,
Expand Down Expand Up @@ -336,7 +336,7 @@ func TestDeleteObservatoryPageTests(t *testing.T) {
}
`)
}
mux.HandleFunc("/zones/"+testZoneID+"/speed_api/pages/"+escapedTestURL+"/tests", handler)
mux.HandleFunc("/zones/"+testZoneID+"/speed_api/pages/"+testURL+"/tests", handler)
want := 2
count, err := client.DeleteObservatoryPageTests(context.Background(), ZoneIdentifier(testZoneID), DeleteObservatoryPageTestsParams{
URL: testURL,
Expand Down Expand Up @@ -364,7 +364,7 @@ func TestGetObservatoryPageTest(t *testing.T) {
}
`, pageTestJSON)
}
mux.HandleFunc("/zones/"+testZoneID+"/speed_api/pages/"+escapedTestURL+"/tests/"+observatoryTestID, handler)
mux.HandleFunc("/zones/"+testZoneID+"/speed_api/pages/"+testURL+"/tests/"+observatoryTestID, handler)
want := pageTest
test, err := client.GetObservatoryPageTest(context.Background(), ZoneIdentifier(testZoneID), GetObservatoryPageTestParams{
TestID: observatoryTestID,
Expand Down Expand Up @@ -393,7 +393,7 @@ func TestCreateObservatoryScheduledPageTest(t *testing.T) {
}
`, scheduledPageTestJSON)
}
mux.HandleFunc("/zones/"+testZoneID+"/speed_api/schedule/"+escapedTestURL, handler)
mux.HandleFunc("/zones/"+testZoneID+"/speed_api/schedule/"+testURL, handler)
want := scheduledPageTest
pages, err := client.CreateObservatoryScheduledPageTest(context.Background(), ZoneIdentifier(testZoneID), CreateObservatoryScheduledPageTestParams{
Frequency: frequency,
Expand Down Expand Up @@ -422,7 +422,7 @@ func TestObservatoryScheduledPageTest(t *testing.T) {
}
`, scheduleJSON)
}
mux.HandleFunc("/zones/"+testZoneID+"/speed_api/schedule/"+escapedTestURL, handler)
mux.HandleFunc("/zones/"+testZoneID+"/speed_api/schedule/"+testURL, handler)
want := schedule
schedule, err := client.GetObservatoryScheduledPageTest(context.Background(), ZoneIdentifier(testZoneID), GetObservatoryScheduledPageTestParams{
URL: testURL,
Expand All @@ -446,13 +446,13 @@ func TestDeleteObservatoryScheduledPageTest(t *testing.T) {
"success": true,
"errors": [],
"messages": [],
"result": {
"result": {
"count": 2
}
}
`)
}
mux.HandleFunc("/zones/"+testZoneID+"/speed_api/schedule/"+escapedTestURL, handler)
mux.HandleFunc("/zones/"+testZoneID+"/speed_api/schedule/"+testURL, handler)
want := 2
count, err := client.DeleteObservatoryScheduledPageTest(context.Background(), ZoneIdentifier(testZoneID), DeleteObservatoryScheduledPageTestParams{
URL: testURL,
Expand Down
7 changes: 3 additions & 4 deletions pages_project.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"fmt"
"net/http"
"net/url"
"time"

"github.com/goccy/go-json"
Expand Down Expand Up @@ -255,7 +254,7 @@ func (api *API) GetPagesProject(ctx context.Context, rc *ResourceContainer, proj
return PagesProject{}, ErrMissingAccountID
}

uri := fmt.Sprintf("/accounts/%s/pages/projects/%s", rc.Identifier, url.PathEscape(projectName))
uri := fmt.Sprintf("/accounts/%s/pages/projects/%s", rc.Identifier, projectName)
res, err := api.makeRequestContext(ctx, http.MethodGet, uri, nil)
if err != nil {
return PagesProject{}, err
Expand Down Expand Up @@ -300,7 +299,7 @@ func (api *API) UpdatePagesProject(ctx context.Context, rc *ResourceContainer, p
return PagesProject{}, ErrMissingIdentifier
}

uri := fmt.Sprintf("/accounts/%s/pages/projects/%s", rc.Identifier, url.PathEscape(params.ID))
uri := fmt.Sprintf("/accounts/%s/pages/projects/%s", rc.Identifier, params.ID)
res, err := api.makeRequestContext(ctx, http.MethodPatch, uri, params)
if err != nil {
return PagesProject{}, err
Expand All @@ -320,7 +319,7 @@ func (api *API) DeletePagesProject(ctx context.Context, rc *ResourceContainer, p
if rc.Identifier == "" {
return ErrMissingAccountID
}
uri := fmt.Sprintf("/accounts/%s/pages/projects/%s", rc.Identifier, url.PathEscape(projectName))
uri := fmt.Sprintf("/accounts/%s/pages/projects/%s", rc.Identifier, projectName)
res, err := api.makeRequestContext(ctx, http.MethodDelete, uri, nil)
if err != nil {
return err
Expand Down
6 changes: 3 additions & 3 deletions pages_project_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ func TestPagesProject(t *testing.T) {
}`, testPagesProjectResponse)
}

mux.HandleFunc("/accounts/"+testAccountID+"/pages/projects/Test%20Pages%20Project", handler)
mux.HandleFunc("/accounts/"+testAccountID+"/pages/projects/Test Pages Project", handler)

_, err := client.GetPagesProject(context.Background(), AccountIdentifier(""), "Test Pages Project")
if assert.Error(t, err) {
Expand Down Expand Up @@ -631,7 +631,7 @@ func TestUpdatePagesProject(t *testing.T) {
}`, testPagesProjectResponse)
}

mux.HandleFunc("/accounts/"+testAccountID+"/pages/projects/Test%20Pages%20Project", handler)
mux.HandleFunc("/accounts/"+testAccountID+"/pages/projects/Test Pages Project", handler)

_, err := client.UpdatePagesProject(context.Background(), AccountIdentifier(""), *updateAttributes)
if assert.Error(t, err) {
Expand Down Expand Up @@ -659,7 +659,7 @@ func TestDeletePagesProject(t *testing.T) {
}`)
}

mux.HandleFunc("/accounts/"+testAccountID+"/pages/projects/Test%20Pages%20Project", handler)
mux.HandleFunc("/accounts/"+testAccountID+"/pages/projects/Test Pages Project", handler)

err := client.DeletePagesProject(context.Background(), AccountIdentifier(""), "Test Pages Project")
if assert.Error(t, err) {
Expand Down
9 changes: 4 additions & 5 deletions tunnel_routes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"
"io"
"net/http"
"net/url"
"testing"
"time"

Expand Down Expand Up @@ -83,7 +82,7 @@ func TestTunnelRouteForIP(t *testing.T) {
}`)
}

mux.HandleFunc("/accounts/"+testAccountID+"/teamnet/routes/ip/"+url.PathEscape("10.1.0.137"), handler)
mux.HandleFunc("/accounts/"+testAccountID+"/teamnet/routes/ip/10.1.0.137", handler)

ts, _ := time.Parse(time.RFC3339Nano, "2021-01-25T18:22:34.317854Z")
want := TunnelRoute{
Expand Down Expand Up @@ -126,7 +125,7 @@ func TestCreateTunnelRoute(t *testing.T) {
}`)
}

mux.HandleFunc("/accounts/"+testAccountID+"/teamnet/routes/network/"+url.PathEscape("10.0.0.0/16"), handler)
mux.HandleFunc("/accounts/"+testAccountID+"/teamnet/routes/network/10.0.0.0/16", handler)

ts, _ := time.Parse(time.RFC3339Nano, "2021-01-25T18:22:34.317854Z")
want := TunnelRoute{
Expand Down Expand Up @@ -185,7 +184,7 @@ func TestUpdateTunnelRoute(t *testing.T) {
VirtualNetworkID: "9f322de4-5988-4945-b770-f1d6ac200f86",
}

mux.HandleFunc("/accounts/"+testAccountID+"/teamnet/routes/network/"+url.PathEscape("10.0.0.0/16"), handler)
mux.HandleFunc("/accounts/"+testAccountID+"/teamnet/routes/network/10.0.0.0/16", handler)
tunnel, err := client.UpdateTunnelRoute(context.Background(), AccountIdentifier(testAccountID), TunnelRoutesUpdateParams{TunnelID: testTunnelID, Network: "10.0.0.0/16", Comment: "foo", VirtualNetworkID: "9f322de4-5988-4945-b770-f1d6ac200f86"})

if assert.NoError(t, err) {
Expand Down Expand Up @@ -217,7 +216,7 @@ func TestDeleteTunnelRoute(t *testing.T) {
}`)
}

mux.HandleFunc("/accounts/"+testAccountID+"/teamnet/routes/network/"+url.PathEscape("10.0.0.0/16"), handler)
mux.HandleFunc("/accounts/"+testAccountID+"/teamnet/routes/network/10.0.0.0/16", handler)
err := client.DeleteTunnelRoute(context.Background(), AccountIdentifier(testAccountID), TunnelRoutesDeleteParams{Network: "10.0.0.0/16", VirtualNetworkID: "9f322de4-5988-4945-b770-f1d6ac200f86"})
assert.NoError(t, err)
}

0 comments on commit 89eab58

Please sign in to comment.