@@ -10,39 +10,6 @@ import (
1010 "github.com/stretchr/testify/assert"
1111)
1212
13- func TestRunEslintToString (t * testing.T ) {
14- homeDirectory , err := os .UserHomeDir ()
15- if err != nil {
16- log .Fatal (err .Error ())
17- }
18- currentDirectory , err := os .Getwd ()
19- if err != nil {
20- log .Fatal (err .Error ())
21- }
22- testDirectory := "testdata/repositories/test1"
23- repositoryToAnalyze := filepath .Join (testDirectory , "src" )
24- sarifOutputFile := filepath .Join (testDirectory , "sarif.json" )
25- eslintInstallationDirectory := filepath .Join (homeDirectory , ".cache/codacy-cli-v2/tools/eslint" )
26- nodeBinary := "node"
27-
28- eslintOutput , err := RunEslintToString (repositoryToAnalyze , eslintInstallationDirectory , nodeBinary )
29- if err != nil {
30- log .Fatal (err .Error ())
31- }
32-
33- expectedSarifBytes , err := os .ReadFile (sarifOutputFile )
34- if err != nil {
35- log .Fatal (err .Error ())
36- }
37-
38- filePrefix := "file://" + currentDirectory + "/"
39- actualSarif := strings .ReplaceAll (eslintOutput , filePrefix , "" )
40-
41- expectedSarif := string (expectedSarifBytes )
42-
43- assert .Equal (t , expectedSarif , actualSarif , "output did not match expected" )
44- }
45-
4613func TestRunEslintToFile (t * testing.T ) {
4714 homeDirectory , err := os .UserHomeDir ()
4815 if err != nil {
@@ -61,10 +28,7 @@ func TestRunEslintToFile(t *testing.T) {
6128 eslintInstallationDirectory := filepath .Join (homeDirectory , ".cache/codacy-cli-v2/tools/eslint" )
6229 nodeBinary := "node"
6330
64- err = RunEslintToFile (repositoryToAnalyze , eslintInstallationDirectory , nodeBinary , tempDir )
65- if err != nil {
66- log .Fatal (err .Error ())
67- }
31+ RunEslint (repositoryToAnalyze , eslintInstallationDirectory , nodeBinary , sarifOutputFile )
6832
6933 expectedSarifBytes , err := os .ReadFile (sarifOutputFile )
7034 if err != nil {
0 commit comments