Skip to content

Commit

Permalink
refactor: Move to better directory finding in tests
Browse files Browse the repository at this point in the history
`analysistest` want `src/` dir
  • Loading branch information
eugercek committed Aug 13, 2023
1 parent ace33af commit 41fdaeb
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 13 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ For instance, it would prevent code like `if 10 = x`, which is invalid and would

Because `if x = 10 { ... } ` is invalid syntax in Go, there's no need for yoda conditions.

# Install and Usage
# Installation and Usage

```bash
go install github.com/eugercek/noyoda/cmd/noyoda
Expand Down
15 changes: 3 additions & 12 deletions noyoda_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,21 @@
package noyoda

import (
"os"
"testing"

"golang.org/x/tools/go/analysis/analysistest"
)

//nolint:gochecknoglobals
var testDir string

func init() {
cur, _ := os.Getwd()
testDir = cur + "/testdata/"
}

func TestIf(t *testing.T) {
t.Parallel()

analysistest.Run(t, testDir+"ifcond", NewAnalyzer())
analysistest.Run(t, analysistest.TestData(), NewAnalyzer(), "ifcond")
}

func TestSwitch(t *testing.T) {
t.Parallel()

analysistest.Run(t, testDir+"switchcond", NewAnalyzer())
analysistest.Run(t, analysistest.TestData(), NewAnalyzer(), "switchcond")
}

func TestConst(t *testing.T) {
Expand All @@ -37,5 +28,5 @@ func TestConst(t *testing.T) {
panic(err)
}

analysistest.Run(t, testDir+"constcond", a)
analysistest.Run(t, analysistest.TestData(), a, "constcond")
}
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 41fdaeb

Please sign in to comment.