fix: Code for category
This commit is contained in:
@@ -254,11 +254,17 @@ func (s stubCategoryReader) GetByID(_ context.Context, id uuid.UUID) (domain.Cat
|
||||
return domain.Category{ID: id}, nil
|
||||
}
|
||||
|
||||
func (s stubCategoryReader) GetByCode(_ context.Context, code string) (domain.Category, error) {
|
||||
if !s.exists {
|
||||
return domain.Category{}, domain.ErrNotFound
|
||||
}
|
||||
return domain.Category{ID: uuid.New(), Code: code}, nil
|
||||
}
|
||||
|
||||
func validUpload() UploadInput {
|
||||
body := `{"type":"FeatureCollection","features":[]}`
|
||||
return UploadInput{
|
||||
CategoryID: uuid.New(),
|
||||
Code: "POP",
|
||||
Name: "Population",
|
||||
Filename: "data.geojson",
|
||||
FileType: domain.FileTypeVector,
|
||||
@@ -278,7 +284,6 @@ func TestDatasetService_Upload_Validation(t *testing.T) {
|
||||
name string
|
||||
mutate func(*UploadInput)
|
||||
}{
|
||||
{"missing code", func(in *UploadInput) { in.Code = "" }},
|
||||
{"invalid file type", func(in *UploadInput) { in.FileType = "bogus" }},
|
||||
{"unknown extension", func(in *UploadInput) { in.Filename = "data.txt" }},
|
||||
{"extension/type mismatch", func(in *UploadInput) { in.Filename = "data.tif" }}, // .tif is raster
|
||||
@@ -732,7 +737,7 @@ func TestDatasetService_ListSummaries_ClampsPaging(t *testing.T) {
|
||||
svc := newDatasetService(repo, &stubStore{}, true)
|
||||
|
||||
// page < 1 -> 1, pageSize > max -> MaxPageSize, offset = 0.
|
||||
res, err := svc.ListSummaries(context.Background(), nil, 0, 10_000)
|
||||
res, err := svc.ListSummaries(context.Background(), nil, nil, 0, 10_000)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
@@ -747,7 +752,7 @@ func TestDatasetService_ListSummaries_ClampsPaging(t *testing.T) {
|
||||
}
|
||||
|
||||
// page 3, pageSize 20 -> offset 40.
|
||||
if _, err := svc.ListSummaries(context.Background(), nil, 3, 20); err != nil {
|
||||
if _, err := svc.ListSummaries(context.Background(), nil, nil, 3, 20); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if repo.lastOffset != 40 || repo.lastLimit != 20 {
|
||||
|
||||
Reference in New Issue
Block a user