Skip to content

Commit

Permalink
Fixed the few remaining linting issues in generator package
Browse files Browse the repository at this point in the history
Signed-off-by: Frederic BIDON <[email protected]>
  • Loading branch information
fredbi authored and casualjim committed Aug 19, 2019
1 parent 4d79150 commit 1a8a72f
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 11 deletions.
7 changes: 4 additions & 3 deletions generator/model_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,13 +310,14 @@ func TestGenerateModel_Zeroes(t *testing.T) {
case "io.ReadCloser":
continue
default:
if strings.HasPrefix(v.Value.GoType, "[]") || strings.HasPrefix(v.Value.GoType, "map[") { // akin to slice or map
switch {
case strings.HasPrefix(v.Value.GoType, "[]") || strings.HasPrefix(v.Value.GoType, "map["): // akin to slice or map
assert.True(t, strings.HasPrefix(v.Value.Zero(), "make("))

} else if strings.HasPrefix(v.Value.GoType, "models.") {
case strings.HasPrefix(v.Value.GoType, "models."):
assert.True(t, strings.HasPrefix(v.Value.Zero(), "new("))

} else { // akin to string
default: // akin to string
rex := regexp.MustCompile(regexp.QuoteMeta(v.Value.GoType) + `\(".*"\)`)
assert.True(t, rex.MatchString(v.Value.Zero()))
k := v.Value
Expand Down
2 changes: 1 addition & 1 deletion generator/moreschemavalidation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ func init() {
testedModels = make([]*modelFixture, 0, 50)
noLines = []string{}
todo = []string{`TODO`}
validatable = append(todo, `Validate(`)
validatable = append([]string{`Validate(`}, todo...)
warning = []string{`warning`}
}

Expand Down
2 changes: 1 addition & 1 deletion generator/operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ func (b *codeGenOpBuilder) MakeOperation() (GenOperation, error) {
idMapping[p.In][p.Name] = swag.ToGoName(p.Name)
}
seenIds[p.Name] = append(seenIds[p.Name], p.In)
if strings.ToLower(p.Name) == strings.ToLower(timeoutName) {
if strings.EqualFold(p.Name, timeoutName) {
timeoutName = renameTimeout(seenIds, timeoutName)
}
}
Expand Down
7 changes: 4 additions & 3 deletions generator/parameter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1211,13 +1211,14 @@ func assertParams(t *testing.T, fixtureConfig map[string]map[string][]string, fi
for fixtureIndex, fixtureContents := range fixtureConfig {
var gen codeGenOpBuilder
var err error
if minimalFlatten && !withExpand {
switch {
case minimalFlatten && !withExpand:
// proceed with minimal spec flattening
gen, err = opBuilder(fixtureIndex, fixture)
} else if !minimalFlatten {
case !minimalFlatten:
// proceed with full flattening
gen, err = opBuilderWithFlatten(fixtureIndex, fixture)
} else {
default:
// proceed with spec expansion
gen, err = opBuilderWithExpand(fixtureIndex, fixture)
}
Expand Down
7 changes: 4 additions & 3 deletions generator/support_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,12 @@ func TestCheckPrefixFetchRelPath(t *testing.T) {
item.path = strings.Replace(item.path, "/", "\\", -1)
}

if actualok != item.ok {
switch {
case actualok != item.ok:
t.Errorf("checkPrefixAndFetchRelativePath(%s, %s): expected %v, actual %v", item.childpath, item.parentpath, item.ok, actualok)
} else if actualpath != item.path {
case actualpath != item.path:
t.Errorf("checkPrefixAndFetchRelativePath(%s, %s): expected %s, actual %s", item.childpath, item.parentpath, item.path, actualpath)
} else {
default:
continue
}
}
Expand Down

0 comments on commit 1a8a72f

Please sign in to comment.