This repository was archived by the owner on Apr 10, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 267
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set errcheck -ignoretests when tests are not enabled (#377)
* Add -ignoretest to errcheck when checking tests is not enabled Add a test for var substitution Remove unused vars from linterState Signed-off-by: Daniel Nephin <dnephin@gmail.com> * Use not_tests for unparam as well
- Loading branch information
1 parent
7f9672e
commit 9165748
Showing
3 changed files
with
80 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package main | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestLinterStateCommand(t *testing.T) { | ||
varsDefault := Vars{"tests": "", "not_tests": "true"} | ||
varsWithTest := Vars{"tests": "true", "not_tests": ""} | ||
|
||
var testcases = []struct { | ||
linter string | ||
vars Vars | ||
expected string | ||
}{ | ||
{ | ||
linter: "errcheck", | ||
vars: varsWithTest, | ||
expected: `errcheck -abspath `, | ||
}, | ||
{ | ||
linter: "errcheck", | ||
vars: varsDefault, | ||
expected: `errcheck -abspath -ignoretests`, | ||
}, | ||
{ | ||
linter: "gotype", | ||
vars: varsDefault, | ||
expected: `gotype -e `, | ||
}, | ||
{ | ||
linter: "gotype", | ||
vars: varsWithTest, | ||
expected: `gotype -e -t`, | ||
}, | ||
{ | ||
linter: "structcheck", | ||
vars: varsDefault, | ||
expected: `structcheck `, | ||
}, | ||
{ | ||
linter: "structcheck", | ||
vars: varsWithTest, | ||
expected: `structcheck -t`, | ||
}, | ||
{ | ||
linter: "unparam", | ||
vars: varsDefault, | ||
expected: `unparam -tests=false`, | ||
}, | ||
{ | ||
linter: "unparam", | ||
vars: varsWithTest, | ||
expected: `unparam `, | ||
}, | ||
} | ||
|
||
for _, testcase := range testcases { | ||
ls := linterState{ | ||
Linter: getLinterByName(testcase.linter, LinterConfig{}), | ||
vars: testcase.vars, | ||
} | ||
assert.Equal(t, testcase.expected, ls.command()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters