@@ -0,0 +1,219 @@
8+func TestGetContextValue(t *testing.T) {
11+ setup func(ctx context.Context) context.Context
17+ name: "returns string value",
18+ setup: func(ctx context.Context) context.Context {
19+ return context.WithValue(ctx, "testKey", "testValue")
26+ name: "returns default when key not found",
27+ setup: func(ctx context.Context) context.Context {
31+ defaultValue: "default",
35+ name: "returns default when type mismatch",
36+ setup: func(ctx context.Context) context.Context {
37+ return context.WithValue(ctx, "testKey", 123) // int, not string
40+ defaultValue: "default",
44+ name: "returns bool value",
45+ setup: func(ctx context.Context) context.Context {
46+ return context.WithValue(ctx, "boolKey", true)
53+ name: "returns int value",
54+ setup: func(ctx context.Context) context.Context {
55+ return context.WithValue(ctx, "intKey", 42)
63+ for _, tt := range tests {
64+ t.Run(tt.name, func(t *testing.T) {
65+ ctx := tt.setup(context.Background())
68+ switch tt.defaultValue.(type) {
70+ got = getContextValue(ctx, tt.key, tt.defaultValue.(string))
72+ got = getContextValue(ctx, tt.key, tt.defaultValue.(bool))
74+ got = getContextValue(ctx, tt.key, tt.defaultValue.(int))
78+ t.Errorf("getContextValue() = %v, want %v", got, tt.want)
84+func TestGetSessionFromContext(t *testing.T) {
91+ name: "returns session ID when present",
92+ ctx: context.WithValue(context.Background(), SessionIDContextKey, "session-123"),
96+ name: "returns empty string when not present",
97+ ctx: context.Background(),
101+ name: "returns empty string when wrong type",
102+ ctx: context.WithValue(context.Background(), SessionIDContextKey, 123),
107+ for _, tt := range tests {
108+ t.Run(tt.name, func(t *testing.T) {
109+ got := GetSessionFromContext(tt.ctx)
111+ t.Errorf("GetSessionFromContext() = %v, want %v", got, tt.want)
117+func TestGetMessageFromContext(t *testing.T) {
124+ name: "returns message ID when present",
125+ ctx: context.WithValue(context.Background(), MessageIDContextKey, "msg-456"),
129+ name: "returns empty string when not present",
130+ ctx: context.Background(),
134+ name: "returns empty string when wrong type",
135+ ctx: context.WithValue(context.Background(), MessageIDContextKey, 456),
140+ for _, tt := range tests {
141+ t.Run(tt.name, func(t *testing.T) {
142+ got := GetMessageFromContext(tt.ctx)
144+ t.Errorf("GetMessageFromContext() = %v, want %v", got, tt.want)
150+func TestGetSupportsImagesFromContext(t *testing.T) {
157+ name: "returns true when present and true",
158+ ctx: context.WithValue(context.Background(), SupportsImagesContextKey, true),
162+ name: "returns false when present and false",
163+ ctx: context.WithValue(context.Background(), SupportsImagesContextKey, false),
167+ name: "returns false when not present",
168+ ctx: context.Background(),
172+ name: "returns false when wrong type",
173+ ctx: context.WithValue(context.Background(), SupportsImagesContextKey, "true"),
178+ for _, tt := range tests {
179+ t.Run(tt.name, func(t *testing.T) {
180+ got := GetSupportsImagesFromContext(tt.ctx)
182+ t.Errorf("GetSupportsImagesFromContext() = %v, want %v", got, tt.want)
188+func TestGetModelNameFromContext(t *testing.T) {
195+ name: "returns model name when present",
196+ ctx: context.WithValue(context.Background(), ModelNameContextKey, "claude-opus-4"),
197+ want: "claude-opus-4",
200+ name: "returns empty string when not present",
201+ ctx: context.Background(),
205+ name: "returns empty string when wrong type",
206+ ctx: context.WithValue(context.Background(), ModelNameContextKey, 789),
211+ for _, tt := range tests {
212+ t.Run(tt.name, func(t *testing.T) {
213+ got := GetModelNameFromContext(tt.ctx)
215+ t.Errorf("GetModelNameFromContext() = %v, want %v", got, tt.want)