Skip to content
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
30 changes: 30 additions & 0 deletions conformance/runner/go/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,15 @@ func runTest(tc TestCase) TestResult {
var mu sync.Mutex
var requestCount int
var requestTimes []time.Time
var requestPaths []string

// Create mock server that serves responses in sequence
responseIndex := 0
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
mu.Lock()
requestCount++
requestTimes = append(requestTimes, time.Now())
requestPaths = append(requestPaths, r.URL.Path)
idx := responseIndex
responseIndex++
mu.Unlock()
Expand Down Expand Up @@ -258,6 +260,17 @@ func runTest(tc TestCase) TestResult {
}
sdkResp, sdkErr = client.UpdateTimesheetEntry(ctx, testAccountID, projectId, entryId, body)

case "GetProjectTimeline":
projectId := getInt64Param(tc.PathParams, "projectId")
sdkResp, sdkErr = client.GetProjectTimeline(ctx, testAccountID, projectId)

case "GetProgressReport":
sdkResp, sdkErr = client.GetProgressReport(ctx, testAccountID)

case "GetPersonProgress":
personId := getInt64Param(tc.PathParams, "personId")
sdkResp, sdkErr = client.GetPersonProgress(ctx, testAccountID, personId)

default:
return TestResult{
Name: tc.Name,
Expand Down Expand Up @@ -327,6 +340,23 @@ func runTest(tc TestCase) TestResult {
Message: fmt.Sprintf("Expected status code %d, got %d", expected, sdkResp.StatusCode),
}
}

case "requestPath":
expected := assertion.Expected.(string)
if len(requestPaths) == 0 {
return TestResult{
Name: tc.Name,
Passed: false,
Message: "Expected a request to be made, but no requests were recorded",
}
}
if requestPaths[0] != expected {
return TestResult{
Name: tc.Name,
Passed: false,
Message: fmt.Sprintf("Expected request path %q, got %q", expected, requestPaths[0]),
}
}
}
}

Expand Down
22 changes: 22 additions & 0 deletions conformance/runner/ruby/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,16 @@ def call(operation, path_params: {}, query_params: {}, body: nil)
todolist_id: path_params["todolistId"],
content: body["content"]
)
when "GetProjectTimeline"
@account.timeline.get_project_timeline(
project_id: path_params["projectId"]
).to_a
when "GetProgressReport"
@account.reports.progress.to_a
when "GetPersonProgress"
@account.reports.person_progress(
person_id: path_params["personId"]
)
else
raise "Unknown operation: #{operation}"
end
Expand Down Expand Up @@ -185,6 +195,18 @@ def verify_assertions(result:, error:)
unless actual == expected
failures << "Expected #{path} to be #{expected}, got #{actual}"
end

when "requestPath"
expected = assertion["expected"]
requests = @tracker.requests
if requests.empty?
failures << "Expected a request to be made, but no requests were recorded"
else
actual_path = URI.parse(requests.first[:uri]).path
unless actual_path == expected
failures << "Expected request path #{expected.inspect}, got #{actual_path.inspect}"
end
end
end
end

Expand Down
3 changes: 2 additions & 1 deletion conformance/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@
"headerPresent",
"headerValue",
"errorType",
"noError"
"noError",
"requestPath"
]
},
"expected": {
Expand Down
49 changes: 49 additions & 0 deletions conformance/tests/paths.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
[
{
"name": "Project timeline uses /projects/ path",
"description": "Verifies that GetProjectTimeline constructs the URL path using /projects/{projectId}/ not /buckets/{projectId}/",
"operation": "GetProjectTimeline",
"method": "GET",
"path": "/projects/{projectId}/timeline.json",
Comment thread
jeremy marked this conversation as resolved.
"pathParams": {"projectId": 12345},
"mockResponses": [
{"status": 200, "body": []}
],
"assertions": [
{"type": "requestPath", "expected": "/999/projects/12345/timeline.json"},
{"type": "noError"}
],
"tags": ["path", "timeline"]
},
{
"name": "Progress report uses /reports/ path",
"description": "Verifies that GetProgressReport constructs the URL path using /reports/progress.json",
"operation": "GetProgressReport",
"method": "GET",
"path": "/reports/progress.json",
"mockResponses": [
{"status": 200, "body": []}
],
"assertions": [
{"type": "requestPath", "expected": "/999/reports/progress.json"},
{"type": "noError"}
],
"tags": ["path", "reports"]
},
{
"name": "Person progress uses /reports/users/ path",
"description": "Verifies that GetPersonProgress constructs the URL path using /reports/users/progress/{personId}",
"operation": "GetPersonProgress",
"method": "GET",
"path": "/reports/users/progress/{personId}",
"pathParams": {"personId": 45678},
"mockResponses": [
{"status": 200, "body": []}
],
"assertions": [
{"type": "requestPath", "expected": "/999/reports/users/progress/45678"},
{"type": "noError"}
],
"tags": ["path", "reports"]
}
]
34 changes: 17 additions & 17 deletions go/pkg/basecamp/url-routes.json
Original file line number Diff line number Diff line change
Expand Up @@ -1403,23 +1403,6 @@
}
}
},
{
"pattern": "/{accountId}/buckets/{projectId}/timeline",
"resource": null,
"operations": {
"GET": "GetProjectTimeline"
},
"params": {
"accountId": {
"role": "account",
"type": "string"
},
"projectId": {
"role": "bucket",
"type": "int64"
}
}
},
{
"pattern": "/{accountId}/buckets/{projectId}/timesheet",
"resource": "Schedule",
Expand Down Expand Up @@ -2020,6 +2003,23 @@
}
}
},
{
"pattern": "/{accountId}/projects/{projectId}/timeline",
"resource": null,
"operations": {
"GET": "GetProjectTimeline"
},
"params": {
"accountId": {
"role": "account",
"type": "string"
},
"projectId": {
"role": "bucket",
"type": "int64"
}
}
},
{
"pattern": "/{accountId}/reports/progress",
"resource": null,
Expand Down
Loading
Loading