shared_test.go

 1package claudetool
 2
 3import (
 4	"context"
 5	"testing"
 6)
 7
 8func TestWithWorkingDir(t *testing.T) {
 9	ctx := context.Background()
10	wd := "/test/working/dir"
11
12	newCtx := WithWorkingDir(ctx, wd)
13	if newCtx == nil {
14		t.Fatal("WithWorkingDir returned nil context")
15	}
16}
17
18func TestWorkingDir(t *testing.T) {
19	ctx := context.Background()
20	wd := "/test/working/dir"
21
22	// Test with working dir set
23	ctxWithWd := WithWorkingDir(ctx, wd)
24	result := WorkingDir(ctxWithWd)
25
26	if result != wd {
27		t.Errorf("expected %q, got %q", wd, result)
28	}
29
30	// Test without working dir set
31	result = WorkingDir(ctx)
32	if result != "" {
33		t.Errorf("expected empty string, got %q", result)
34	}
35}
36
37func TestWithSessionID(t *testing.T) {
38	ctx := context.Background()
39	sessionID := "test-session-id"
40
41	newCtx := WithSessionID(ctx, sessionID)
42	if newCtx == nil {
43		t.Fatal("WithSessionID returned nil context")
44	}
45}
46
47func TestSessionID(t *testing.T) {
48	ctx := context.Background()
49	sessionID := "test-session-id"
50
51	// Test with session ID set
52	ctxWithSession := WithSessionID(ctx, sessionID)
53	result := SessionID(ctxWithSession)
54
55	if result != sessionID {
56		t.Errorf("expected %q, got %q", sessionID, result)
57	}
58
59	// Test without session ID set
60	result = SessionID(ctx)
61	if result != "" {
62		t.Errorf("expected empty string, got %q", result)
63	}
64}