This repository was archived by the owner on Apr 30, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +18
-19
lines changed Expand file tree Collapse file tree 2 files changed +18
-19
lines changed Original file line number Diff line number Diff line change @@ -46,13 +46,14 @@ func TestGenerateWithImports(t *testing.T) {
46
46
ToDo : map [string ]string {
47
47
"imports/oneref_verbose" : "Figure out how to disambiguate struct literals from the struct-with-braces-and-one-element case" ,
48
48
},
49
- ImportMappers : map [string ]func (string ) (string , error ){
50
- "imports/imports" : func (s string ) (string , error ) {
51
- if s == "example.com/dep" {
52
- return "@example/deps" , nil
53
- }
54
- return s , nil
55
- },
49
+ }
50
+
51
+ importMappers := map [string ]func (s string ) (string , error ){
52
+ "imports/imports" : func (s string ) (string , error ) {
53
+ if s == "example.com/dep" {
54
+ return "@example/deps" , nil
55
+ }
56
+ return s , nil
56
57
},
57
58
}
58
59
@@ -64,9 +65,16 @@ func TestGenerateWithImports(t *testing.T) {
64
65
t .Fatal (v .Err ())
65
66
}
66
67
68
+ im := func (s string ) (string , error ) {
69
+ return "" , nil
70
+ }
71
+ if i , ok := importMappers [t .Name ]; ok {
72
+ im = i
73
+ }
74
+
67
75
b , err := cuetsy .Generate (v , cuetsy.Config {
68
76
Export : true ,
69
- ImportMapper : t . ImportMapperFn ,
77
+ ImportMapper : im ,
70
78
})
71
79
if err != nil {
72
80
errors .Print (t , err , nil )
Original file line number Diff line number Diff line change @@ -59,8 +59,6 @@ type TxTarTest struct {
59
59
60
60
// ToDo is a map of tests that should be skipped now, but should be fixed.
61
61
ToDo map [string ]string
62
-
63
- ImportMappers map [string ]func (string ) (string , error )
64
62
}
65
63
66
64
// A Test represents a single test based on a .txtar file.
@@ -86,7 +84,7 @@ type Test struct {
86
84
87
85
hasGold bool
88
86
89
- ImportMapperFn func ( s string ) ( string , error )
87
+ Name string
90
88
}
91
89
92
90
func (t * Test ) Write (b []byte ) (n int , err error ) {
@@ -270,6 +268,7 @@ func (x *TxTarTest) Run(t *testing.T, f func(tc *Test)) {
270
268
T : t ,
271
269
Archive : a ,
272
270
Dir : filepath .Dir (filepath .Join (dir , fullpath )),
271
+ Name : testName ,
273
272
274
273
prefix : path .Join ("out" , x .Name ),
275
274
}
@@ -292,14 +291,6 @@ func (x *TxTarTest) Run(t *testing.T, f func(tc *Test)) {
292
291
t .Skip (msg )
293
292
}
294
293
295
- if im , ok := x .ImportMappers [testName ]; ok {
296
- tc .ImportMapperFn = im
297
- } else {
298
- tc .ImportMapperFn = func (s string ) (string , error ) {
299
- return "" , nil
300
- }
301
- }
302
-
303
294
f (tc )
304
295
305
296
update := false
You can’t perform that action at this time.
0 commit comments