fadd
This commit is contained in:
@@ -38,6 +38,31 @@ func TestHashIDCard(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestGenerateCurlCommandHeaderOrder(t *testing.T) {
|
||||
cmd := generateCurlCommand("POST", "https://example.com/openapi/v1/a01/x", map[string]string{
|
||||
"signature": "sig",
|
||||
"Content-Type": "application/json",
|
||||
"nonce": "n",
|
||||
"clientId": "cid",
|
||||
"timestamp": "1",
|
||||
}, `{"name":"a"}`)
|
||||
wantOrder := []string{
|
||||
"-H 'Content-Type: application/json'",
|
||||
"-H 'clientId: cid'",
|
||||
"-H 'timestamp: 1'",
|
||||
"-H 'nonce: n'",
|
||||
"-H 'signature: sig'",
|
||||
}
|
||||
pos := 0
|
||||
for _, part := range wantOrder {
|
||||
idx := strings.Index(cmd[pos:], part)
|
||||
if idx < 0 {
|
||||
t.Fatalf("missing ordered header %q in:\n%s", part, cmd)
|
||||
}
|
||||
pos += idx + len(part)
|
||||
}
|
||||
}
|
||||
|
||||
func sandboxService() *YuyuechaService {
|
||||
return NewYuyuechaService(ServiceConfig{
|
||||
BaseURL: "https://sandbox-api.yuyuecha.com",
|
||||
|
||||
Reference in New Issue
Block a user