7b03f04670
- Refactored `requestExecutionMetadata` to handle empty `Idempotency-Key` gracefully. - Added test to validate metadata inclusion of execution session without idempotency key.
21 lines
652 B
Go
21 lines
652 B
Go
package handlers
|
|
|
|
import (
|
|
"testing"
|
|
|
|
coreexecutor "github.com/router-for-me/CLIProxyAPI/v6/sdk/cliproxy/executor"
|
|
"golang.org/x/net/context"
|
|
)
|
|
|
|
func TestRequestExecutionMetadataIncludesExecutionSessionWithoutIdempotencyKey(t *testing.T) {
|
|
ctx := WithExecutionSessionID(context.Background(), "session-1")
|
|
|
|
meta := requestExecutionMetadata(ctx)
|
|
if got := meta[coreexecutor.ExecutionSessionMetadataKey]; got != "session-1" {
|
|
t.Fatalf("ExecutionSessionMetadataKey = %v, want %q", got, "session-1")
|
|
}
|
|
if _, ok := meta[idempotencyKeyMetadataKey]; ok {
|
|
t.Fatalf("unexpected idempotency key in metadata: %v", meta[idempotencyKeyMetadataKey])
|
|
}
|
|
}
|