Establish native CommandKit command composition
This commit is contained in:
31
internal/adapter/cli/app_test.go
Normal file
31
internal/adapter/cli/app_test.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"go.maximumdirect.net/commandkit"
|
||||
)
|
||||
|
||||
func TestNativeMetadataWithoutConfiguration(t *testing.T) {
|
||||
t.Chdir(t.TempDir())
|
||||
for _, args := range [][]string{
|
||||
{"--help"}, {"version"}, {"run", "--help"}, {"serve", "--help"},
|
||||
{"config", "scopes"}, {"config", "show", "--help"},
|
||||
{"promptkit", "--help"}, {"promptkit", "list", "prompts", "--help"},
|
||||
{"completion", "bash"}, {"completion", "zsh"}, {"completion", "fish"},
|
||||
} {
|
||||
t.Run(strings.Join(args, " "), func(t *testing.T) {
|
||||
var out, diagnostics bytes.Buffer
|
||||
outcome := Execute(context.Background(), commandkit.Identity{Name: "scriptorium", Version: "test-version", Revision: "test-revision"}, args, &out, &diagnostics)
|
||||
if outcome.Status != 0 || out.Len() == 0 {
|
||||
t.Fatalf("outcome=%#v stdout=%q stderr=%q", outcome, out.String(), diagnostics.String())
|
||||
}
|
||||
if args[0] == "version" && !strings.Contains(out.String(), "test-version") {
|
||||
t.Fatalf("version identity missing: %q", out.String())
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user