Skip to content

Commit e75fb4e

Browse files
committed
Test escaped owner and repo path segments
1 parent fd9422d commit e75fb4e

1 file changed

Lines changed: 22 additions & 9 deletions

File tree

‎pkg/github/automation_tags_test.go‎

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,15 @@ func Test_ListAutomationTags(t *testing.T) {
4949
for _, protocol := range []string{inventory.ProtocolVersionMultiRoundTrip, "2025-11-25"} {
5050
t.Run(protocol, func(t *testing.T) {
5151
for _, tc := range []struct {
52-
name string
53-
args map[string]any
54-
status int
55-
body string
56-
link string
57-
query string
58-
want string
59-
wantError string
52+
name string
53+
args map[string]any
54+
status int
55+
body string
56+
link string
57+
query string
58+
escapedPath string
59+
want string
60+
wantError string
6061
}{
6162
{
6263
name: "page and additive fields",
@@ -78,6 +79,14 @@ func Test_ListAutomationTags(t *testing.T) {
7879
status: http.StatusOK, body: `{"tags":[],"total_count":2}`,
7980
query: "page=3&per_page=1", want: `{"tags":[],"total_count":2,"nextPage":0}`,
8081
},
82+
{
83+
name: "escaped path segments",
84+
args: map[string]any{"owner": "own er/team", "repo": "re/po"},
85+
status: http.StatusOK,
86+
body: `{"tags":[],"total_count":0}`,
87+
escapedPath: "/agents/repos/own%20er%2Fteam/re%2Fpo/automation-tags",
88+
want: `{"tags":[],"total_count":0,"nextPage":0}`,
89+
},
8190
{name: "non-disclosure", status: http.StatusNotFound, body: `{"message":"Not Found"}`, wantError: "404"},
8291
{name: "empty denial", status: http.StatusNotFound, wantError: "404"},
8392
{name: "bad request", status: http.StatusBadRequest, body: `{"message":"Bad Request"}`, wantError: "400"},
@@ -109,7 +118,11 @@ func Test_ListAutomationTags(t *testing.T) {
109118
}
110119
assert.Equal(t, "api.github.com", r.URL.Host)
111120
assert.Equal(t, http.MethodGet, r.Method)
112-
assert.Equal(t, "/agents/repos/owner/repo/automation-tags", r.URL.EscapedPath())
121+
escapedPath := tc.escapedPath
122+
if escapedPath == "" {
123+
escapedPath = "/agents/repos/owner/repo/automation-tags"
124+
}
125+
assert.Equal(t, escapedPath, r.URL.EscapedPath())
113126
query := tc.query
114127
if query == "" {
115128
query = "page=1&per_page=30"

0 commit comments

Comments
 (0)