6
6
"io/ioutil"
7
7
"os"
8
8
"os/exec"
9
- "path"
9
+ "path/filepath "
10
10
"runtime"
11
11
"testing"
12
12
)
@@ -78,19 +78,19 @@ func TestFileInput(t *testing.T) {
78
78
inputFile := "simple_select_without_from.input.sql"
79
79
expectedOutputFile := "simple_select_without_from.golden.sql"
80
80
81
- expected , err := ioutil .ReadFile (path .Join ("../../testdata" , expectedOutputFile ))
81
+ expected , err := ioutil .ReadFile (filepath .Join ("../../testdata" , expectedOutputFile ))
82
82
if err != nil {
83
83
t .Fatal (err )
84
84
}
85
85
86
- filePath := path .Join ("../../testdata" , inputFile )
86
+ filePath := filepath .Join ("../../testdata" , inputFile )
87
87
output , err := sqlfmt (nil , filePath )
88
88
if err != nil {
89
89
t .Fatalf ("sqlfmt failed with %s: %v" , filePath , err )
90
90
}
91
91
92
92
if bytes .Compare (output , expected ) != 0 {
93
- actualFileName := path .Join ("tmp" , "TestFileInput.sql" )
93
+ actualFileName := filepath .Join ("tmp" , "TestFileInput.sql" )
94
94
err = ioutil .WriteFile (actualFileName , output , os .ModePerm )
95
95
if err != nil {
96
96
t .Fatal (err )
@@ -103,20 +103,20 @@ func TestFileInput(t *testing.T) {
103
103
func TestFileFormatInPlace (t * testing.T ) {
104
104
inputFile := "simple_select_without_from.input.sql"
105
105
expectedOutputFile := "simple_select_without_from.golden.sql"
106
- expectedOutputPath := path .Join ("../../testdata" , expectedOutputFile )
106
+ expectedOutputPath := filepath .Join ("../../testdata" , expectedOutputFile )
107
107
108
108
expected , err := ioutil .ReadFile (expectedOutputPath )
109
109
if err != nil {
110
110
t .Fatal (err )
111
111
}
112
112
113
- sourcePath := path .Join ("../../testdata" , inputFile )
113
+ sourcePath := filepath .Join ("../../testdata" , inputFile )
114
114
source , err := ioutil .ReadFile (sourcePath )
115
115
if err != nil {
116
116
t .Fatal (err )
117
117
}
118
118
119
- tmpFilePath := path .Join ("tmp" , inputFile )
119
+ tmpFilePath := filepath .Join ("tmp" , inputFile )
120
120
err = ioutil .WriteFile (tmpFilePath , source , os .ModePerm )
121
121
if err != nil {
122
122
t .Fatal (err )
@@ -155,19 +155,19 @@ func TestMultipleFileFormatInPlace(t *testing.T) {
155
155
var err error
156
156
args := []string {"-w" }
157
157
for i , _ := range tests {
158
- sourcePath := path .Join ("../../testdata" , tests [i ].Name + ".input.sql" )
158
+ sourcePath := filepath .Join ("../../testdata" , tests [i ].Name + ".input.sql" )
159
159
tests [i ].Source , err = ioutil .ReadFile (sourcePath )
160
160
if err != nil {
161
161
t .Fatal (err )
162
162
}
163
163
164
- expectedOutputPath := path .Join ("../../testdata" , tests [i ].Name + ".golden.sql" )
164
+ expectedOutputPath := filepath .Join ("../../testdata" , tests [i ].Name + ".golden.sql" )
165
165
tests [i ].Expected , err = ioutil .ReadFile (expectedOutputPath )
166
166
if err != nil {
167
167
t .Fatal (err )
168
168
}
169
169
170
- tests [i ].TmpFilePath = path .Join ("tmp" , tests [i ].Name + ".sql" )
170
+ tests [i ].TmpFilePath = filepath .Join ("tmp" , tests [i ].Name + ".sql" )
171
171
err = ioutil .WriteFile (tests [i ].TmpFilePath , tests [i ].Source , os .ModePerm )
172
172
if err != nil {
173
173
t .Fatal (err )
@@ -209,8 +209,8 @@ func TestSqlFmtAll(t *testing.T) {
209
209
}
210
210
211
211
testName := fi .Name ()[:len (fi .Name ())- 10 ]
212
- inputPath := path .Join ("../../testdata" , fi .Name ())
213
- goldenPath := path .Join ("../../testdata" , testName + ".golden.sql" )
212
+ inputPath := filepath .Join ("../../testdata" , fi .Name ())
213
+ goldenPath := filepath .Join ("../../testdata" , testName + ".golden.sql" )
214
214
215
215
input , err := ioutil .ReadFile (inputPath )
216
216
if err != nil {
@@ -231,7 +231,7 @@ func TestSqlFmtAll(t *testing.T) {
231
231
}
232
232
233
233
if bytes .Compare (output , expected ) != 0 {
234
- actualFileName := path .Join ("tmp" , fmt .Sprintf ("%s.sql" , testName ))
234
+ actualFileName := filepath .Join ("tmp" , fmt .Sprintf ("%s.sql" , testName ))
235
235
err = ioutil .WriteFile (actualFileName , output , os .ModePerm )
236
236
if err != nil {
237
237
t .Fatal (err )
0 commit comments