Skip to content

Commit 67a41cb

Browse files
committed
remember to stage changes
1 parent c4aabc2 commit 67a41cb

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

api/api.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import (
1616
"github.com/coder/code-marketplace/storage"
1717
)
1818

19+
const MaxPageSizeDefault int = 200
20+
1921
// QueryRequest implements an untyped object. It is the data sent to the API to
2022
// query for extensions.
2123
// https://github.com/microsoft/vscode/blob/a69f95fdf3dc27511517eef5ff62b21c7a418015/src/vs/platform/extensionManagement/common/extensionGalleryService.ts#L338-L342
@@ -74,6 +76,10 @@ func New(options *Options) *API {
7476
options.RateLimit = 512
7577
}
7678

79+
if options.MaxPageSize == 0 {
80+
options.MaxPageSize = MaxPageSizeDefault
81+
}
82+
7783
r := chi.NewRouter()
7884

7985
r.Use(

api/api_test.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ func TestAPI(t *testing.T) {
119119
}},
120120
},
121121
Response: &httpapi.ErrorResponse{
122-
Message: "Invalid page size",
123-
Detail: "Check that the page size is between zero and fifty",
122+
Message: "The page size must be between 0 and 200",
123+
Detail: "Contact an administrator to increase the page size",
124124
},
125125
},
126126
{
@@ -255,9 +255,10 @@ func TestAPI(t *testing.T) {
255255

256256
logger := slogtest.Make(t, &slogtest.Options{IgnoreErrors: true}).Leveled(slog.LevelDebug)
257257
apiServer := api.New(&api.Options{
258-
Database: testutil.NewMockDB(exts),
259-
Storage: testutil.NewMockStorage(),
260-
Logger: logger,
258+
Database: testutil.NewMockDB(exts),
259+
Storage: testutil.NewMockStorage(),
260+
Logger: logger,
261+
MaxPageSize: api.MaxPageSizeDefault,
261262
})
262263

263264
server := httptest.NewServer(apiServer.Handler)

cli/server.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ import (
2121
"github.com/coder/code-marketplace/storage"
2222
)
2323

24-
const maxPageSizeDefault int = 200
25-
2624
func server() *cobra.Command {
2725
var (
2826
address string
@@ -140,7 +138,7 @@ func server() *cobra.Command {
140138
}
141139

142140
cmd.Flags().StringVar(&extdir, "extensions-dir", "", "The path to extensions.")
143-
cmd.Flags().IntVar(&maxpagesize, "max-page-size", maxPageSizeDefault, "The maximum number of pages to request")
141+
cmd.Flags().IntVar(&maxpagesize, "max-page-size", api.MaxPageSizeDefault, "The maximum number of pages to request")
144142
cmd.Flags().StringVar(&artifactory, "artifactory", "", "Artifactory server URL.")
145143
cmd.Flags().StringVar(&repo, "repo", "", "Artifactory repository.")
146144
cmd.Flags().StringVar(&address, "address", "127.0.0.1:3001", "The address on which to serve the marketplace API.")

0 commit comments

Comments
 (0)