Skip to content

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

internal/cmd/generate/commands/gentests/generator.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,10 @@ func (g *Generator) genFileHeader() {
195195
import (
196196
encjson "encoding/json"
197197
encyaml "gopkg.in/yaml.v2"
198+
"fmt"
198199
"context"
199200
"crypto/tls"
201+
"net/url"
200202
"testing"
201203
"time"
202204
@@ -206,10 +208,11 @@ import (
206208
207209
var (
208210
// Prevent compilation errors for unused packages
211+
_ = fmt.Printf
209212
_ = encjson.NewDecoder
210213
_ = encyaml.NewDecoder
211214
_ = tls.Certificate{}
212-
_ = fmt.Printf
215+
_ = url.QueryEscape
213216
)` + "\n")
214217
}
215218

@@ -957,7 +960,12 @@ func (g *Generator) genAction(a Action, skipBody ...bool) {
957960
}
958961
value = fmt.Sprintf("%d", dur.Nanoseconds())
959962
default:
960-
value = fmt.Sprintf("%q", v)
963+
if strings.HasSuffix(k, "ID") {
964+
value = fmt.Sprintf("url.QueryEscape(%q)", v)
965+
} else {
966+
value = fmt.Sprintf("%q", v)
967+
}
968+
961969
}
962970
}
963971
g.w(value)

0 commit comments

Comments
 (0)