Skip to content

Commit a588b67

Browse files
committed
test: update Test_parseOpenAIResponseBody to use raw JSON for request body
Signed-off-by: Sivanantham Chinnaiyan <[email protected]>
1 parent ca47cf0 commit a588b67

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

internal/extproc/responses_processor_test.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ package extproc
77

88
import (
99
"context"
10-
"encoding/json"
1110
"errors"
1211
"io"
1312
"log/slog"
@@ -38,16 +37,16 @@ func TestResponsesProcessorFactory(t *testing.T) {
3837

3938
func Test_parseOpenAIResponseBody(t *testing.T) {
4039
t.Run("ok", func(t *testing.T) {
41-
req := openai.ResponseRequest{Model: "m1"}
42-
b, _ := json.Marshal(req)
40+
// Use raw JSON to avoid issues with union-type marshalling in test structs.
41+
b := []byte(`{"model":"m1"}`)
4342
model, rr, err := parseOpenAIResponseBody(&extprocv3.HttpBody{Body: b})
4443
require.NoError(t, err)
4544
require.Equal(t, "m1", model)
46-
require.Equal(t, &req, rr)
45+
// Ensure parsed request has the expected model value
46+
require.Equal(t, "m1", rr.Model)
4747
})
4848
t.Run("error missing model", func(t *testing.T) {
49-
req := openai.ResponseRequest{}
50-
b, _ := json.Marshal(req)
49+
b := []byte(`{}`)
5150
_, _, err := parseOpenAIResponseBody(&extprocv3.HttpBody{Body: b})
5251
require.Error(t, err)
5352
})

0 commit comments

Comments
 (0)