| 502 | } |
| 503 | |
| 504 | func TestClient_EnvOptions(t *testing.T) { |
| 505 | t.Run("should store custom environment variables", func(t *testing.T) { |
| 506 | client := NewClient(&ClientOptions{ |
| 507 | Env: []string{"FOO=bar", "BAZ=qux"}, |
| 508 | }) |
| 509 | |
| 510 | if len(client.options.Env) != 2 { |
| 511 | t.Errorf("Expected 2 environment variables, got %d", len(client.options.Env)) |
| 512 | } |
| 513 | if client.options.Env[0] != "FOO=bar" { |
| 514 | t.Errorf("Expected first env var to be 'FOO=bar', got %q", client.options.Env[0]) |
| 515 | } |
| 516 | if client.options.Env[1] != "BAZ=qux" { |
| 517 | t.Errorf("Expected second env var to be 'BAZ=qux', got %q", client.options.Env[1]) |
| 518 | } |
| 519 | }) |
| 520 | |
| 521 | t.Run("should default to inherit from current process", func(t *testing.T) { |
| 522 | client := NewClient(&ClientOptions{}) |
| 523 | |
| 524 | if want := os.Environ(); !reflect.DeepEqual(client.options.Env, want) { |
| 525 | t.Errorf("Expected Env to be %v, got %v", want, client.options.Env) |
| 526 | } |
| 527 | }) |
| 528 | |
| 529 | t.Run("should default to inherit from current process with nil options", func(t *testing.T) { |
| 530 | client := NewClient(nil) |
| 531 | |
| 532 | if want := os.Environ(); !reflect.DeepEqual(client.options.Env, want) { |
| 533 | t.Errorf("Expected Env to be %v, got %v", want, client.options.Env) |
| 534 | } |
| 535 | }) |
| 536 | |
| 537 | t.Run("should allow empty environment", func(t *testing.T) { |
| 538 | client := NewClient(&ClientOptions{ |
| 539 | Env: []string{}, |
| 540 | }) |
| 541 | |
| 542 | if client.options.Env == nil { |
| 543 | t.Error("Expected Env to be non-nil empty slice") |
| 544 | } |
| 545 | if len(client.options.Env) != 0 { |
| 546 | t.Errorf("Expected 0 environment variables, got %d", len(client.options.Env)) |
| 547 | } |
| 548 | }) |
| 549 | } |
| 550 | |
| 551 | func TestClient_SessionIdleTimeoutSeconds(t *testing.T) { |
| 552 | t.Run("should store SessionIdleTimeoutSeconds option", func(t *testing.T) { |