Skip to content

Commit

Permalink
test: use specific language in testhelper
Browse files Browse the repository at this point in the history
  • Loading branch information
didroe committed Jun 13, 2024
1 parent c3af4dd commit 2d064bb
Show file tree
Hide file tree
Showing 44 changed files with 149 additions and 93 deletions.
7 changes: 4 additions & 3 deletions pkg/languages/golang/golang_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
_ "embed"
"testing"

"github.com/bearer/bearer/pkg/languages/golang"
"github.com/bearer/bearer/pkg/languages/testhelper"
)

Expand All @@ -17,13 +18,13 @@ var scopeRule []byte
var importRule []byte

func TestFlow(t *testing.T) {
testhelper.GetRunner(t, loggerRule, "Go").RunTest(t, "./testdata/testcases/flow", ".snapshots/flow/")
testhelper.GetRunner(t, loggerRule, golang.Get()).RunTest(t, "./testdata/testcases/flow", ".snapshots/flow/")
}

func TestScope(t *testing.T) {
testhelper.GetRunner(t, scopeRule, "Go").RunTest(t, "./testdata/scope", ".snapshots/")
testhelper.GetRunner(t, scopeRule, golang.Get()).RunTest(t, "./testdata/scope", ".snapshots/")
}

func TestImport(t *testing.T) {
testhelper.GetRunner(t, importRule, "Go").RunTest(t, "./testdata/import", ".snapshots/")
testhelper.GetRunner(t, importRule, golang.Get()).RunTest(t, "./testdata/import", ".snapshots/")
}
4 changes: 2 additions & 2 deletions pkg/languages/java/java_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ var loggerRule []byte
var scopeRule []byte

func TestFlow(t *testing.T) {
testhelper.GetRunner(t, loggerRule, "Java").RunTest(t, "./testdata/testcases/flow", ".snapshots/flow/")
testhelper.GetRunner(t, loggerRule, java.Get()).RunTest(t, "./testdata/testcases/flow", ".snapshots/flow/")
}

func TestScope(t *testing.T) {
testhelper.GetRunner(t, scopeRule, "Java").RunTest(t, "./testdata/scope", ".snapshots/")
testhelper.GetRunner(t, scopeRule, java.Get()).RunTest(t, "./testdata/scope", ".snapshots/")
}

func TestPattern(t *testing.T) {
Expand Down
13 changes: 7 additions & 6 deletions pkg/languages/javascript/javascript_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
_ "embed"
"testing"

"github.com/bearer/bearer/pkg/languages/javascript"
"github.com/bearer/bearer/pkg/languages/testhelper"
)

Expand All @@ -26,25 +27,25 @@ var patternVariablesRule []byte
var scopeRule []byte

func TestFlow(t *testing.T) {
testhelper.GetRunner(t, datatypeRule, "Javascript").RunTest(t, "./testdata/testcases/flow", ".snapshots/flow/")
testhelper.GetRunner(t, datatypeRule, javascript.Get()).RunTest(t, "./testdata/testcases/flow", ".snapshots/flow/")
}

func TestObjectDeconstructing(t *testing.T) {
testhelper.GetRunner(t, deconstructingRule, "Javascript").RunTest(t, "./testdata/testcases/object-deconstructing", ".snapshots/object-deconstructing/")
testhelper.GetRunner(t, deconstructingRule, javascript.Get()).RunTest(t, "./testdata/testcases/object-deconstructing", ".snapshots/object-deconstructing/")
}

func TestImport(t *testing.T) {
testhelper.GetRunner(t, importRule, "Javascript").RunTest(t, "./testdata/import", ".snapshots/import/")
testhelper.GetRunner(t, importRule, javascript.Get()).RunTest(t, "./testdata/import", ".snapshots/import/")
}

func TestString(t *testing.T) {
testhelper.GetRunner(t, insecureURLRule, "Javascript").RunTest(t, "./testdata/testcases/string", ".snapshots/string/")
testhelper.GetRunner(t, insecureURLRule, javascript.Get()).RunTest(t, "./testdata/testcases/string", ".snapshots/string/")
}

func TestPatternVariables(t *testing.T) {
testhelper.GetRunner(t, patternVariablesRule, "Javascript").RunTest(t, "./testdata/pattern_variables", ".snapshots/")
testhelper.GetRunner(t, patternVariablesRule, javascript.Get()).RunTest(t, "./testdata/pattern_variables", ".snapshots/")
}

func TestScope(t *testing.T) {
testhelper.GetRunner(t, scopeRule, "Javascript").RunTest(t, "./testdata/scope", ".snapshots/")
testhelper.GetRunner(t, scopeRule, javascript.Get()).RunTest(t, "./testdata/scope", ".snapshots/")
}
6 changes: 3 additions & 3 deletions pkg/languages/php/php_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ var scopeRule []byte
var mdRule []byte

func TestFlow(t *testing.T) {
testhelper.GetRunner(t, loggerRule, "PHP").RunTest(t, "./testdata/testcases/flow", ".snapshots/flow/")
testhelper.GetRunner(t, loggerRule, php.Get()).RunTest(t, "./testdata/testcases/flow", ".snapshots/flow/")
}

func TestScope(t *testing.T) {
testhelper.GetRunner(t, scopeRule, "PHP").RunTest(t, "./testdata/scope", ".snapshots/")
testhelper.GetRunner(t, scopeRule, php.Get()).RunTest(t, "./testdata/scope", ".snapshots/")
}

func TestConst(t *testing.T) {
testhelper.GetRunner(t, mdRule, "PHP").RunTest(t, "./testdata/md", ".snapshots/")
testhelper.GetRunner(t, mdRule, php.Get()).RunTest(t, "./testdata/md", ".snapshots/")
}

func TestAnalyzer(t *testing.T) {
Expand Down
13 changes: 7 additions & 6 deletions pkg/languages/python/python_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
_ "embed"
"testing"

"github.com/bearer/bearer/pkg/languages/python"
"github.com/bearer/bearer/pkg/languages/testhelper"
)

Expand All @@ -26,25 +27,25 @@ var subscriptRule []byte
var pairRule []byte

func TestDatatypes(t *testing.T) {
testhelper.GetRunner(t, datatypesRule, "python").RunTest(t, "./testdata/datatypes", ".snapshots/")
testhelper.GetRunner(t, datatypesRule, python.Get()).RunTest(t, "./testdata/datatypes", ".snapshots/")
}

func TestScope(t *testing.T) {
testhelper.GetRunner(t, scopeRule, "python").RunTest(t, "./testdata/scope", ".snapshots/")
testhelper.GetRunner(t, scopeRule, python.Get()).RunTest(t, "./testdata/scope", ".snapshots/")
}

func TestFlow(t *testing.T) {
testhelper.GetRunner(t, flowRule, "python").RunTest(t, "./testdata/flow", ".snapshots/")
testhelper.GetRunner(t, flowRule, python.Get()).RunTest(t, "./testdata/flow", ".snapshots/")
}

func TestImport(t *testing.T) {
testhelper.GetRunner(t, importRule, "python").RunTest(t, "./testdata/import", ".snapshots/")
testhelper.GetRunner(t, importRule, python.Get()).RunTest(t, "./testdata/import", ".snapshots/")
}

func TestSubscript(t *testing.T) {
testhelper.GetRunner(t, subscriptRule, "python").RunTest(t, "./testdata/subscript", ".snapshots/")
testhelper.GetRunner(t, subscriptRule, python.Get()).RunTest(t, "./testdata/subscript", ".snapshots/")
}

func TestPair(t *testing.T) {
testhelper.GetRunner(t, pairRule, "python").RunTest(t, "./testdata/pair", ".snapshots/")
testhelper.GetRunner(t, pairRule, python.Get()).RunTest(t, "./testdata/pair", ".snapshots/")
}
7 changes: 4 additions & 3 deletions pkg/languages/ruby/ruby_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
_ "embed"
"testing"

"github.com/bearer/bearer/pkg/languages/ruby"
"github.com/bearer/bearer/pkg/languages/testhelper"
)

Expand All @@ -17,13 +18,13 @@ var patternVariablesRule []byte
var scopeRule []byte

func TestRuby(t *testing.T) {
testhelper.GetRunner(t, loggerRule, "Ruby").RunTest(t, "./testdata/testcases", ".snapshots/")
testhelper.GetRunner(t, loggerRule, ruby.Get()).RunTest(t, "./testdata/testcases", ".snapshots/")
}

func TestPatternVariables(t *testing.T) {
testhelper.GetRunner(t, patternVariablesRule, "Ruby").RunTest(t, "./testdata/pattern_variables", ".snapshots/")
testhelper.GetRunner(t, patternVariablesRule, ruby.Get()).RunTest(t, "./testdata/pattern_variables", ".snapshots/")
}

func TestScope(t *testing.T) {
testhelper.GetRunner(t, scopeRule, "Ruby").RunTest(t, "./testdata/scope", ".snapshots/")
testhelper.GetRunner(t, scopeRule, ruby.Get()).RunTest(t, "./testdata/scope", ".snapshots/")
}
Loading

0 comments on commit 2d064bb

Please sign in to comment.