MCPcopy Index your code
hub / github.com/jetify-com/devbox / TestWriteDevboxShellrcBash

Function TestWriteDevboxShellrcBash

internal/devbox/shell_test.go:394–440  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

392}
393
394func 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
442func TestWriteDevboxShellrcWithZDOTDIR(t *testing.T) {
443 tmpDir := t.TempDir()

Callers

nothing calls this directly

Calls 2

writeDevboxShellrcMethod · 0.95
ErrorMethod · 0.45

Tested by

no test coverage detected