Skip to content

Commit

Permalink
[DDO-3215] Fix v3 version upsert paths (#327)
Browse files Browse the repository at this point in the history
  • Loading branch information
jack-r-warren authored Oct 12, 2023
1 parent 0f97f22 commit 79e6c41
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
32 changes: 32 additions & 0 deletions sherlock/internal/api/api_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package api

import (
"embed"
"github.com/stretchr/testify/assert"
"path"
"regexp"
"testing"
)

//go:embed *
var apiFiles embed.FS
var capsInApiPathRegex = regexp.MustCompile(`/api/\w*[A-Z]`)

func TestApiFiles(t *testing.T) {
validateApiPathsInDirectory(t, ".")
}

func validateApiPathsInDirectory(t *testing.T, subdirectory string) {
entries, err := apiFiles.ReadDir(subdirectory)
assert.NoError(t, err)
for _, entry := range entries {
filesystemPath := path.Join(subdirectory, entry.Name())
if entry.IsDir() {
validateApiPathsInDirectory(t, filesystemPath)
} else {
data, err := apiFiles.ReadFile(filesystemPath)
assert.NoError(t, err, "file %s read error", filesystemPath)
assert.Falsef(t, capsInApiPathRegex.Match(data), "file %s contains an API path with capitalized letters (matching %s)", filesystemPath, capsInApiPathRegex.String())
}
}
}
2 changes: 1 addition & 1 deletion sherlock/internal/api/sherlock/app_version_v3_upsert.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
// @param appVersion body AppVersionV3Create true "The AppVersion to upsert"
// @success 201 {object} AppVersionV3
// @failure 400,403,404,407,409,500 {object} errors.ErrorResponse
// @router /api/appVersions/v3 [post]
// @router /api/app-versions/v3 [post]
func appVersionsV3Upsert(ctx *gin.Context) {
db, err := authentication.MustUseDB(ctx)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion sherlock/internal/api/sherlock/chart_version_v3_upsert.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
// @param chartVersion body ChartVersionV3Create true "The ChartVersion to upsert"
// @success 201 {object} ChartVersionV3
// @failure 400,403,404,407,409,500 {object} errors.ErrorResponse
// @router /api/chartVersions/v3 [post]
// @router /api/chart-versions/v3 [post]
func chartVersionsV3Upsert(ctx *gin.Context) {
db, err := authentication.MustUseDB(ctx)
if err != nil {
Expand Down

0 comments on commit 79e6c41

Please sign in to comment.