(t *testing.T)
| 1094 | } |
| 1095 | |
| 1096 | func TestSession_HookForwardCompatibility(t *testing.T) { |
| 1097 | t.Run("unknown hook type returns nil without error when known hooks are registered", func(t *testing.T) { |
| 1098 | session, cleanup := newTestSession() |
| 1099 | defer cleanup() |
| 1100 | |
| 1101 | // Register known hook handlers to simulate a real session configuration. |
| 1102 | // The handler itself does nothing; it only exists to confirm that even |
| 1103 | // when other hooks are active, an unknown hook type is still ignored. |
| 1104 | session.registerHooks(&SessionHooks{ |
| 1105 | OnPostToolUse: func(input PostToolUseHookInput, invocation HookInvocation) (*PostToolUseHookOutput, error) { |
| 1106 | return nil, nil |
| 1107 | }, |
| 1108 | }) |
| 1109 | |
| 1110 | // "futureUnknownHookType" stands in for a hook type introduced by a |
| 1111 | // newer CLI version that the SDK does not yet know about. |
| 1112 | output, err := session.handleHooksInvoke("futureUnknownHookType", json.RawMessage(`{}`)) |
| 1113 | if err != nil { |
| 1114 | t.Errorf("Expected no error for unknown hook type, got: %v", err) |
| 1115 | } |
| 1116 | if output != nil { |
| 1117 | t.Errorf("Expected nil output for unknown hook type, got: %v", output) |
| 1118 | } |
| 1119 | }) |
| 1120 | |
| 1121 | t.Run("unknown hook type with no hooks registered returns nil without error", func(t *testing.T) { |
| 1122 | session, cleanup := newTestSession() |
| 1123 | defer cleanup() |
| 1124 | |
| 1125 | output, err := session.handleHooksInvoke("futureHookType", json.RawMessage(`{"someField":"value"}`)) |
| 1126 | if err != nil { |
| 1127 | t.Errorf("Expected no error for unknown hook type with no hooks, got: %v", err) |
| 1128 | } |
| 1129 | if output != nil { |
| 1130 | t.Errorf("Expected nil output for unknown hook type with no hooks, got: %v", output) |
| 1131 | } |
| 1132 | }) |
| 1133 | } |
| 1134 | |
| 1135 | func TestSession_ElicitationRequestSchema(t *testing.T) { |
| 1136 | t.Run("nil content values are allowed", func(t *testing.T) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…