github.com/alecthomas/gometalinter@v3.0.1-0.20190307123442-32416ab75314+incompatible/execute_test.go (about) 1 package main 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/assert" 7 ) 8 9 func TestLinterStateCommand(t *testing.T) { 10 varsDefault := Vars{"tests": "", "not_tests": "true"} 11 varsWithTest := Vars{"tests": "true", "not_tests": ""} 12 13 var testcases = []struct { 14 linter string 15 vars Vars 16 expected string 17 }{ 18 { 19 linter: "errcheck", 20 vars: varsWithTest, 21 expected: `errcheck -abspath `, 22 }, 23 { 24 linter: "errcheck", 25 vars: varsDefault, 26 expected: `errcheck -abspath -ignoretests`, 27 }, 28 { 29 linter: "gotype", 30 vars: varsDefault, 31 expected: `gotype -e `, 32 }, 33 { 34 linter: "gotype", 35 vars: varsWithTest, 36 expected: `gotype -e -t`, 37 }, 38 { 39 linter: "structcheck", 40 vars: varsDefault, 41 expected: `structcheck `, 42 }, 43 { 44 linter: "structcheck", 45 vars: varsWithTest, 46 expected: `structcheck -t`, 47 }, 48 { 49 linter: "unparam", 50 vars: varsDefault, 51 expected: `unparam -tests=false`, 52 }, 53 { 54 linter: "unparam", 55 vars: varsWithTest, 56 expected: `unparam `, 57 }, 58 } 59 60 for _, testcase := range testcases { 61 ls := linterState{ 62 Linter: getLinterByName(testcase.linter, LinterConfig{}), 63 vars: testcase.vars, 64 } 65 assert.Equal(t, testcase.expected, ls.command()) 66 } 67 }