TestExampleLocalPluginAliases loads the examples/plugins/local project and verifies that aliases defined in the plugin are merged into the parent config, and that an alias defined in the parent overrides the plugin's.
(t *testing.T)
| 366 | // verifies that aliases defined in the plugin are merged into the parent |
| 367 | // config, and that an alias defined in the parent overrides the plugin's. |
| 368 | func TestExampleLocalPluginAliases(t *testing.T) { |
| 369 | exampleDir, err := filepath.Abs( |
| 370 | filepath.Join("..", "..", "examples", "plugins", "local"), |
| 371 | ) |
| 372 | if err != nil { |
| 373 | t.Fatal(err) |
| 374 | } |
| 375 | |
| 376 | cfg, err := Open(exampleDir) |
| 377 | if err != nil { |
| 378 | t.Fatalf("Open(%q) error: %v", exampleDir, err) |
| 379 | } |
| 380 | |
| 381 | lockfile, err := lock.GetFile(&testLockProject{dir: exampleDir}) |
| 382 | if err != nil { |
| 383 | t.Fatalf("lock.GetFile error: %v", err) |
| 384 | } |
| 385 | if err := cfg.LoadRecursive(lockfile); err != nil { |
| 386 | t.Fatalf("LoadRecursive error: %v", err) |
| 387 | } |
| 388 | |
| 389 | want := map[string]string{ |
| 390 | // Parent devbox.json overrides the plugin's "greet" alias. |
| 391 | "greet": "echo greeting-from-parent", |
| 392 | // "plugin_only" is contributed solely by the plugin. |
| 393 | "plugin_only": "echo from-plugin", |
| 394 | } |
| 395 | if diff := cmp.Diff(want, cfg.Aliases()); diff != "" { |
| 396 | t.Errorf("Aliases() mismatch (-want +got):\n%s", diff) |
| 397 | } |
| 398 | } |
| 399 | |
| 400 | func TestDefault(t *testing.T) { |
| 401 | path := filepath.Join(t.TempDir()) |
nothing calls this directly
no test coverage detected