feat: add --format json support to plugin:list
Adds a `--format json` flag to `plugin:list` whose output includes each plugin's install source - for git-based third-party plugins, the git remote URL, the checked-out commit, and the followed branch - so the set of installed plugins can be reconstructed elsewhere. Closes #8798.
This commit is contained in:
45
plugins/plugin/plugin_test.go
Normal file
45
plugins/plugin/plugin_test.go
Normal file
@@ -0,0 +1,45 @@
|
||||
package plugin
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestParsePlugnList(t *testing.T) {
|
||||
output := `plugn: dev
|
||||
00_dokku-standard 0.38.21 enabled dokku core standard plugin
|
||||
smoke-test-plugin 0.2.0 disabled a third party plugin
|
||||
bare-plugin 1.0.0 enabled`
|
||||
|
||||
plugins := parsePlugnList(output)
|
||||
if len(plugins) != 3 {
|
||||
t.Fatalf("expected 3 plugins, got %d", len(plugins))
|
||||
}
|
||||
|
||||
first := plugins[0]
|
||||
if first.Name != "00_dokku-standard" {
|
||||
t.Errorf("expected name 00_dokku-standard, got %q", first.Name)
|
||||
}
|
||||
if first.Version != "0.38.21" {
|
||||
t.Errorf("expected version 0.38.21, got %q", first.Version)
|
||||
}
|
||||
if !first.Enabled {
|
||||
t.Errorf("expected plugin to be enabled")
|
||||
}
|
||||
if first.Description != "dokku core standard plugin" {
|
||||
t.Errorf("expected multi-word description, got %q", first.Description)
|
||||
}
|
||||
|
||||
if plugins[1].Enabled {
|
||||
t.Errorf("expected smoke-test-plugin to be disabled")
|
||||
}
|
||||
if plugins[1].Description != "a third party plugin" {
|
||||
t.Errorf("expected multi-word description, got %q", plugins[1].Description)
|
||||
}
|
||||
|
||||
if plugins[2].Name != "bare-plugin" {
|
||||
t.Errorf("expected name bare-plugin, got %q", plugins[2].Name)
|
||||
}
|
||||
if plugins[2].Description != "" {
|
||||
t.Errorf("expected empty description, got %q", plugins[2].Description)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user