32 lines
1.0 KiB
Go
32 lines
1.0 KiB
Go
|
|
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())
|
||
|
|
}
|
||
|
|
})
|
||
|
|
}
|
||
|
|
}
|