Skip to content

Commit 3786e6c

Browse files
fix: resolve staticcheck SA4031 lint in Go schema test
1 parent 5b2eb21 commit 3786e6c

1 file changed

Lines changed: 18 additions & 27 deletions

File tree

go/session_test.go

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -387,27 +387,19 @@ func TestSession_ElicitationRequestSchema(t *testing.T) {
387387
t.Run("elicitation.requested passes full schema to handler", func(t *testing.T) {
388388
// Verify the schema extraction logic from handleBroadcastEvent
389389
// preserves type, properties, and required.
390-
schemaType := RequestedSchemaType("object")
391-
required := []string{"name", "age"}
392-
schema := &RequestedSchema{
393-
Type: schemaType,
394-
Properties: map[string]any{
395-
"name": map[string]any{"type": "string"},
396-
"age": map[string]any{"type": "number"},
397-
},
398-
Required: required,
390+
properties := map[string]any{
391+
"name": map[string]any{"type": "string"},
392+
"age": map[string]any{"type": "number"},
399393
}
394+
required := []string{"name", "age"}
400395

401396
// Replicate the schema extraction logic from handleBroadcastEvent
402-
var requestedSchema map[string]any
403-
if schema != nil {
404-
requestedSchema = map[string]any{
405-
"type": string(schema.Type),
406-
"properties": schema.Properties,
407-
}
408-
if len(schema.Required) > 0 {
409-
requestedSchema["required"] = schema.Required
410-
}
397+
requestedSchema := map[string]any{
398+
"type": "object",
399+
"properties": properties,
400+
}
401+
if len(required) > 0 {
402+
requestedSchema["required"] = required
411403
}
412404

413405
if requestedSchema == nil {
@@ -430,19 +422,18 @@ func TestSession_ElicitationRequestSchema(t *testing.T) {
430422
})
431423

432424
t.Run("schema without required omits required key", func(t *testing.T) {
433-
schema := &RequestedSchema{
434-
Type: RequestedSchemaType("object"),
435-
Properties: map[string]any{
436-
"optional_field": map[string]any{"type": "string"},
437-
},
425+
properties := map[string]any{
426+
"optional_field": map[string]any{"type": "string"},
438427
}
439428

440429
requestedSchema := map[string]any{
441-
"type": string(schema.Type),
442-
"properties": schema.Properties,
430+
"type": "object",
431+
"properties": properties,
443432
}
444-
if len(schema.Required) > 0 {
445-
requestedSchema["required"] = schema.Required
433+
// Simulate: if len(schema.Required) > 0 { ... } — with empty required
434+
var required []string
435+
if len(required) > 0 {
436+
requestedSchema["required"] = required
446437
}
447438

448439
if _, exists := requestedSchema["required"]; exists {

0 commit comments

Comments
 (0)