Skip to content

Commit

Permalink
nitpicker: add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MarioCarrion committed Dec 24, 2018
1 parent 48843e7 commit 2468296
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 0 deletions.
32 changes: 32 additions & 0 deletions nitpicking_test.go
Original file line number Diff line number Diff line change
@@ -1 +1,33 @@
package nitpicking_test

import (
"path/filepath"
"testing"

"github.com/MarioCarrion/nitpicking"
)

func TestNitpicker_Validate(t *testing.T) {
tests := [...]struct {
name string
filename string
expectedError bool
}{
{
"OK",
"nitpicker_valid.go",
false,
},
}

for _, tt := range tests {
t.Run(tt.name, func(ts *testing.T) {
n := nitpicking.Nitpicker{}

if err := n.Validate(filepath.Join("testdata", tt.filename)); tt.expectedError != (err != nil) {

ts.Fatalf("expected error %t, got %s", tt.expectedError, err)
}
})
}
}
13 changes: 13 additions & 0 deletions testdata/imports_valid.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package testdata

import (
"fmt"

"github.com/pkg/errors"

"github.com/MarioCarrion/nitpicking"
)

func ImportsValid() {
fmt.Println("%s", errors.New(""), nitpicking.Nitpicker{})
}
29 changes: 29 additions & 0 deletions testdata/nitpicker_valid.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package testdata

import (
"fmt"
)

const (
FirstConst = "1"
)

const (
SecondConst = "2"
)

type (
Example struct{}
)

var (
varOne = 1
)

func NitpickerValid() {
fmt.Println("")
}

func (*Example) ExampleMethod() {
fmt.Println("")
}
5 changes: 5 additions & 0 deletions validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ func TestImportsValidator_Validate(t *testing.T) {
filename string
expectedError bool
}{
{
"OK",
"imports_valid.go",
false,
},
{
"Error: parenthesized declaration",
"imports_paren.go",
Expand Down

0 comments on commit 2468296

Please sign in to comment.