This commit is contained in:
2026-07-25 14:18:14 +08:00
parent cc2513652e
commit fa55098520
7 changed files with 216 additions and 58 deletions

View File

@@ -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",