Skip to content

Commit

Permalink
Updates Catalog fetch query to order by id
Browse files Browse the repository at this point in the history
Previoulsy, order was not defined due to which test may fail as we
can't say what will be the order so now updated the query to know
for sure.

Signed-off-by: Shivam Mukhade <[email protected]>
  • Loading branch information
SM43 authored and tekton-robot committed Apr 12, 2021
1 parent 2b7d0db commit 1eed82a
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 10 deletions.
10 changes: 5 additions & 5 deletions api/.env.dev
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ POSTGRES_DB="hub"
POSTGRES_USER="postgres"
POSTGRES_PASSWORD="postgres"

GH_CLIENT_ID=""
GH_CLIENT_SECRET=""
GH_CLIENT_ID="client-id"
GH_CLIENT_SECRET="client-secret"

JWT_SIGNING_KEY=""
ACCESS_JWT_EXPIRES_IN=""
REFRESH_JWT_EXPIRES_IN=""
JWT_SIGNING_KEY="TektonHub"
ACCESS_JWT_EXPIRES_IN="1s"
REFRESH_JWT_EXPIRES_IN="1s"

CONFIG_FILE_URL="file://../config.yaml"
2 changes: 1 addition & 1 deletion api/v1/design/catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
)

var _ = Service("catalog", func() {
Description("List of catalogs")
Description("The catalog service provides details about catalogs.")

HTTP(func() {
Path("/v1")
Expand Down
2 changes: 1 addition & 1 deletion api/v1/gen/catalog/service.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/v1/gen/http/cli/hub/cli.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 9 additions & 2 deletions api/v1/service/catalog/catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ func (s *service) List(ctx context.Context) (*catalog.ListResult, error) {

log := s.Logger(ctx)
db := s.DB(ctx)

var all []model.Catalog
if err := db.Find(&all).Error; err != nil {
if err := db.Order("id").Find(&all).Error; err != nil {
log.Error(err)
return nil, internalError
}
Expand All @@ -52,7 +53,13 @@ func (s *service) List(ctx context.Context) (*catalog.ListResult, error) {
}

for _, c := range all {
res.Data = append(res.Data, &catalog.Catalog{ID: c.ID, Name: c.Name, Type: c.Type, URL: c.URL})
res.Data = append(res.Data,
&catalog.Catalog{
ID: c.ID,
Name: c.Name,
Type: c.Type,
URL: c.URL,
})
}

return res, nil
Expand Down

0 comments on commit 1eed82a

Please sign in to comment.