MCPcopy
hub / github.com/asdf-vm/asdf / TestCallbackPath

Function TestCallbackPath

internal/plugins/plugins_test.go:451–471  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

449}
450
451func TestCallbackPath(t *testing.T) {
452 testDataDir := t.TempDir()
453 conf := config.Config{DataDir: testDataDir}
454 _, err := repotest.InstallPlugin("dummy_plugin", testDataDir, testPluginName)
455 assert.Nil(t, err)
456 plugin := New(conf, testPluginName)
457
458 t.Run("returns callback path when callback exists", func(t *testing.T) {
459 path, err := plugin.CallbackPath("install")
460 assert.Nil(t, err)
461 assert.Equal(t, filepath.Base(path), "install")
462 assert.Equal(t, filepath.Base(filepath.Dir(filepath.Dir(path))), plugin.Name)
463 assert.Equal(t, filepath.Base(filepath.Dir(filepath.Dir(filepath.Dir(path)))), "plugins")
464 })
465
466 t.Run("returns error when callback does not exist", func(t *testing.T) {
467 path, err := plugin.CallbackPath("non-existent")
468 assert.Equal(t, err.(NoCallbackError).Error(), "Plugin named lua does not have a callback named non-existent")
469 assert.Equal(t, path, "")
470 })
471}
472
473func TestGetExtensionCommands(t *testing.T) {
474 testDataDir := t.TempDir()

Callers

nothing calls this directly

Calls 5

InstallPluginFunction · 0.92
RunMethod · 0.80
CallbackPathMethod · 0.80
NewFunction · 0.70
ErrorMethod · 0.45

Tested by

no test coverage detected