File tree 1 file changed +10
-12
lines changed
gopls/internal/regtest/workspace 1 file changed +10
-12
lines changed Original file line number Diff line number Diff line change 5
5
package workspace
6
6
7
7
import (
8
- "fmt"
9
8
"strings"
10
9
"testing"
11
10
@@ -104,7 +103,6 @@ use (
104
103
func TestQuickFix_AddGoWork (t * testing.T ) {
105
104
testenv .NeedsGo1Point (t , 18 ) // needs go.work
106
105
107
- v := goVersion (t )
108
106
const files = `
109
107
-- a/go.mod --
110
108
module mod.com/a
@@ -148,37 +146,34 @@ const C = "b"
148
146
name string
149
147
file string
150
148
title string
151
- want string
149
+ want string // expected go.work content, excluding go directive line
152
150
}{
153
151
{
154
152
"use b" ,
155
153
"b/main.go" ,
156
154
"Add a go.work file using this module" ,
157
- fmt .Sprintf (`go 1.%d
158
-
155
+ `
159
156
use ./b
160
- ` , v ),
157
+ ` ,
161
158
},
162
159
{
163
160
"use a" ,
164
161
"a/main.go" ,
165
162
"Add a go.work file using this module" ,
166
- fmt .Sprintf (`go 1.%d
167
-
163
+ `
168
164
use ./a
169
- ` , v ),
165
+ ` ,
170
166
},
171
167
{
172
168
"use all" ,
173
169
"a/main.go" ,
174
170
"Add a go.work file using all modules" ,
175
- fmt .Sprintf (`go 1.%d
176
-
171
+ `
177
172
use (
178
173
./a
179
174
./b
180
175
)
181
- ` , v ),
176
+ ` ,
182
177
},
183
178
}
184
179
@@ -204,6 +199,9 @@ use (
204
199
)
205
200
206
201
got := env .ReadWorkspaceFile ("go.work" )
202
+ // Ignore the `go` directive, which we assume is on the first line of
203
+ // the go.work file. This allows the test to be independent of go version.
204
+ got = strings .Join (strings .Split (got , "\n " )[1 :], "\n " )
207
205
if diff := compare .Text (test .want , got ); diff != "" {
208
206
t .Errorf ("unexpected go.work content:\n %s" , diff )
209
207
}
You can’t perform that action at this time.
0 commit comments