Skip to content

Commit

Permalink
Fix apache#1182: fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolaferraro committed Jan 17, 2020
1 parent 27c2145 commit b50eb05
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
3 changes: 2 additions & 1 deletion pkg/trait/cron.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ type cronInfo struct {
type cronExtractor func(string) *cronInfo

const (
genericCronComponent = "cron"
genericCronComponent = "cron"
genericCronComponentFallback = "camel:quartz"
)

Expand Down Expand Up @@ -339,6 +339,7 @@ func getCronForURI(camelURI string) *cronInfo {
// Specific extractors

// timerToCronInfo converts a timer endpoint to a Kubernetes cron schedule
// nolint: gocritic
func timerToCronInfo(camelURI string) *cronInfo {
if uri.GetQueryParameter(camelURI, "delay") != "" ||
uri.GetQueryParameter(camelURI, "repeatCount") != "" ||
Expand Down
9 changes: 5 additions & 4 deletions pkg/trait/cron_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,9 @@ func TestCronFromURI(t *testing.T) {
}

for _, test := range tests {
t.Run(test.uri, func(t *testing.T) {
uris := []string{test.uri, test.uri2, test.uri3}
thetest := test
t.Run(thetest.uri, func(t *testing.T) {
uris := []string{thetest.uri, thetest.uri2, thetest.uri3}
filtered := make([]string, 0, len(uris))
for _, uri := range uris {
if uri != "" {
Expand All @@ -197,13 +198,13 @@ func TestCronFromURI(t *testing.T) {
if res != nil {
gotCron = res.schedule
}
assert.Equal(t, gotCron, test.cron)
assert.Equal(t, gotCron, thetest.cron)

gotComponents := ""
if res != nil {
gotComponents = strings.Join(res.components, ",")
}
assert.Equal(t, gotComponents, test.components)
assert.Equal(t, gotComponents, thetest.components)
})
}
}
1 change: 0 additions & 1 deletion pkg/util/knative/uri.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (

var uriRegexp = regexp.MustCompile(`^knative:[/]*(channel|endpoint|event)/([A-Za-z0-9.-]+)(?:[/?].*|$)`)
var plainNameRegexp = regexp.MustCompile(`^[A-Za-z0-9.-]+$`)
var queryExtractorRegexp = `^[^?]+\?(?:|.*[&])%s=([^&]+)(?:[&].*|$)`

const (
paramAPIVersion = "apiVersion"
Expand Down
7 changes: 4 additions & 3 deletions pkg/util/uri/uri_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,10 @@ func TestQueryParameter(t *testing.T) {
}

for _, test := range tests {
t.Run(test.uri, func(t *testing.T) {
param := GetQueryParameter(test.uri, test.param)
assert.Equal(t, test.expected, param)
thetest := test
t.Run(thetest.uri, func(t *testing.T) {
param := GetQueryParameter(thetest.uri, thetest.param)
assert.Equal(t, thetest.expected, param)
})
}

Expand Down

0 comments on commit b50eb05

Please sign in to comment.