Skip to content

Commit dd9935e

Browse files
committed
fix: update gitlab test to verify license query param
1 parent ba135e4 commit dd9935e

1 file changed

Lines changed: 18 additions & 8 deletions

File tree

internal/providers/gitlab/properties_test.go

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ func Test_gitlabClient_FetchAllProperties(t *testing.T) {
131131
},
132132
},
133133
{
134-
name: "repository succeeds",
135134
args: args{
136135
ctx: context.TODO(),
137136
getByProps: properties.NewProperties(map[string]any{
@@ -143,19 +142,30 @@ func Test_gitlabClient_FetchAllProperties(t *testing.T) {
143142
properties.RepoPropertyIsPrivate: true,
144143
properties.RepoPropertyIsArchived: false,
145144
properties.RepoPropertyIsFork: false,
145+
RepoPropertyLicense: "mit", // Uses the correct constant
146146
}),
147147
wantErr: false,
148-
gitLabServerMockFunc: func(w http.ResponseWriter, _ *http.Request) {
148+
gitLabServerMockFunc: func(w http.ResponseWriter, r *http.Request) {
149+
// Verify the query parameter you added is being sent
150+
if r.URL.Query().Get("license") != "true" {
151+
t.Errorf("expected query param license=true, got %s", r.URL.RawQuery)
152+
w.WriteHeader(http.StatusBadRequest)
153+
return
154+
}
155+
149156
resp := &gitlab.Project{
150-
ID: 1,
151-
Name: "project-1",
152-
Description: "project-1 description",
153-
Visibility: gitlab.PrivateVisibility,
154-
Archived: false,
155-
ForkedFromProject: nil,
157+
ID: 1,
158+
Name: "project-1",
159+
Description: "project-1 description",
160+
Visibility: gitlab.PrivateVisibility,
161+
Archived: false,
162+
ForkedFromProject: nil,
156163
Namespace: &gitlab.ProjectNamespace{
157164
Path: "group",
158165
},
166+
License: &gitlab.ProjectLicense{
167+
Name: "mit", // Changed Key to Name to match repository_properties.go
168+
},
159169
}
160170

161171
w.Header().Set("Content-Type", "application/json")

0 commit comments

Comments
 (0)