(t *testing.T)
| 392 | } |
| 393 | |
| 394 | func TestWriteDevboxShellrcBash(t *testing.T) { |
| 395 | tmpDir := t.TempDir() |
| 396 | |
| 397 | // Create a test bash rc file |
| 398 | bashrcPath := filepath.Join(tmpDir, ".bashrc") |
| 399 | bashrcContent := "# Test bash configuration\nexport TEST_VAR=value" |
| 400 | err := os.WriteFile(bashrcPath, []byte(bashrcContent), 0o644) |
| 401 | if err != nil { |
| 402 | t.Fatalf("Failed to create test .bashrc: %v", err) |
| 403 | } |
| 404 | |
| 405 | // Create a mock devbox |
| 406 | devbox := &Devbox{projectDir: "/test/project"} |
| 407 | |
| 408 | // Create a bash shell |
| 409 | shell := &DevboxShell{ |
| 410 | devbox: devbox, |
| 411 | name: shBash, |
| 412 | userShellrcPath: bashrcPath, |
| 413 | projectDir: "/test/project", |
| 414 | env: map[string]string{"TEST_ENV": "test_value"}, |
| 415 | } |
| 416 | |
| 417 | // Write the devbox shellrc |
| 418 | shellrcPath, err := shell.writeDevboxShellrc() |
| 419 | if err != nil { |
| 420 | t.Fatalf("Failed to write devbox shellrc: %v", err) |
| 421 | } |
| 422 | |
| 423 | // Read and verify the content |
| 424 | content, err := os.ReadFile(shellrcPath) |
| 425 | if err != nil { |
| 426 | t.Fatalf("Failed to read generated shellrc: %v", err) |
| 427 | } |
| 428 | |
| 429 | contentStr := string(content) |
| 430 | |
| 431 | // Check that it does NOT contain zsh-specific ZDOTDIR handling |
| 432 | if strings.Contains(contentStr, "DEVBOX_ZDOTDIR") { |
| 433 | t.Error("Expected shellrc to NOT contain ZDOTDIR handling for bash") |
| 434 | } |
| 435 | |
| 436 | // Check that it sources the original .bashrc |
| 437 | if !strings.Contains(contentStr, bashrcPath) { |
| 438 | t.Error("Expected shellrc to source the original .bashrc file") |
| 439 | } |
| 440 | } |
| 441 | |
| 442 | func TestWriteDevboxShellrcWithZDOTDIR(t *testing.T) { |
| 443 | tmpDir := t.TempDir() |
nothing calls this directly
no test coverage detected