|
9 | 9 | "regexp" |
10 | 10 | "sync" |
11 | 11 | "testing" |
| 12 | + |
| 13 | + "github.com/github/copilot-sdk/go/rpc" |
12 | 14 | ) |
13 | 15 |
|
14 | 16 | // This file is for unit tests. Where relevant, prefer to add e2e tests in e2e/*.test.go instead |
@@ -223,6 +225,48 @@ func TestClient_URLParsing(t *testing.T) { |
223 | 225 | }) |
224 | 226 | } |
225 | 227 |
|
| 228 | +func TestClient_SessionFsConfig(t *testing.T) { |
| 229 | + t.Run("should throw error when InitialCwd is missing", func(t *testing.T) { |
| 230 | + defer func() { |
| 231 | + if r := recover(); r == nil { |
| 232 | + t.Error("Expected panic for missing SessionFs.InitialCwd") |
| 233 | + } else { |
| 234 | + matched, _ := regexp.MatchString("SessionFs.InitialCwd is required", r.(string)) |
| 235 | + if !matched { |
| 236 | + t.Errorf("Expected panic message to contain 'SessionFs.InitialCwd is required', got: %v", r) |
| 237 | + } |
| 238 | + } |
| 239 | + }() |
| 240 | + |
| 241 | + NewClient(&ClientOptions{ |
| 242 | + SessionFs: &SessionFsConfig{ |
| 243 | + SessionStatePath: "/session-state", |
| 244 | + Conventions: rpc.ConventionsPosix, |
| 245 | + }, |
| 246 | + }) |
| 247 | + }) |
| 248 | + |
| 249 | + t.Run("should throw error when SessionStatePath is missing", func(t *testing.T) { |
| 250 | + defer func() { |
| 251 | + if r := recover(); r == nil { |
| 252 | + t.Error("Expected panic for missing SessionFs.SessionStatePath") |
| 253 | + } else { |
| 254 | + matched, _ := regexp.MatchString("SessionFs.SessionStatePath is required", r.(string)) |
| 255 | + if !matched { |
| 256 | + t.Errorf("Expected panic message to contain 'SessionFs.SessionStatePath is required', got: %v", r) |
| 257 | + } |
| 258 | + } |
| 259 | + }() |
| 260 | + |
| 261 | + NewClient(&ClientOptions{ |
| 262 | + SessionFs: &SessionFsConfig{ |
| 263 | + InitialCwd: "/", |
| 264 | + Conventions: rpc.ConventionsPosix, |
| 265 | + }, |
| 266 | + }) |
| 267 | + }) |
| 268 | +} |
| 269 | + |
226 | 270 | func TestClient_AuthOptions(t *testing.T) { |
227 | 271 | t.Run("should accept GitHubToken option", func(t *testing.T) { |
228 | 272 | client := NewClient(&ClientOptions{ |
|
0 commit comments