(t *testing.T)
| 116 | } |
| 117 | |
| 118 | func TestWriteDevboxShellrcAliases(t *testing.T) { |
| 119 | cfgJSON := `{ |
| 120 | "shell": { |
| 121 | "init_hook": "echo hi" |
| 122 | }, |
| 123 | "aliases": { |
| 124 | "ll": "ls -la", |
| 125 | "gs": "git status", |
| 126 | "say": "echo it's here" |
| 127 | } |
| 128 | }` |
| 129 | dir := t.TempDir() |
| 130 | if err := os.WriteFile( |
| 131 | filepath.Join(dir, "devbox.json"), []byte(cfgJSON), 0o644, |
| 132 | ); err != nil { |
| 133 | t.Fatal(err) |
| 134 | } |
| 135 | cfg, err := devconfig.Open(dir) |
| 136 | if err != nil { |
| 137 | t.Fatalf("Open config error: %v", err) |
| 138 | } |
| 139 | |
| 140 | tests := []struct { |
| 141 | shell name |
| 142 | want []string |
| 143 | }{ |
| 144 | { |
| 145 | shell: shBash, |
| 146 | want: []string{ |
| 147 | `alias gs='git status'`, |
| 148 | `alias ll='ls -la'`, |
| 149 | `alias say='echo it'\''s here'`, |
| 150 | }, |
| 151 | }, |
| 152 | { |
| 153 | shell: shFish, |
| 154 | want: []string{ |
| 155 | `alias gs='git status'`, |
| 156 | `alias ll='ls -la'`, |
| 157 | `alias say='echo it\'s here'`, |
| 158 | }, |
| 159 | }, |
| 160 | } |
| 161 | |
| 162 | for _, test := range tests { |
| 163 | t.Run(string(test.shell), func(t *testing.T) { |
| 164 | s := &DevboxShell{ |
| 165 | devbox: &Devbox{projectDir: dir, cfg: cfg}, |
| 166 | projectDir: dir, |
| 167 | name: test.shell, |
| 168 | } |
| 169 | path, err := s.writeDevboxShellrc() |
| 170 | if err != nil { |
| 171 | t.Fatalf("writeDevboxShellrc error: %v", err) |
| 172 | } |
| 173 | b, err := os.ReadFile(path) |
| 174 | if err != nil { |
| 175 | t.Fatal(err) |
nothing calls this directly
no test coverage detected