feat: add versioning
This commit is contained in:
25
cli_test.go
25
cli_test.go
@@ -2,10 +2,34 @@ package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"regexp"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestVersionCommandPrintsSemanticVersion(t *testing.T) {
|
||||
var output bytes.Buffer
|
||||
handled, err := handleVersionCommand([]string{"--version"}, &output)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !handled || output.String() != "diple "+dipleVersion+"\n" {
|
||||
t.Fatalf("version output = %q, handled=%t", output.String(), handled)
|
||||
}
|
||||
if !regexp.MustCompile(`^0\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$`).MatchString(dipleVersion) {
|
||||
t.Fatalf("version %q is not a pre-1.0 semantic version", dipleVersion)
|
||||
}
|
||||
}
|
||||
|
||||
func TestVersionCommandRejectsAdditionalArguments(t *testing.T) {
|
||||
handled, err := handleVersionCommand(
|
||||
[]string{"--version", "--help"}, &bytes.Buffer{},
|
||||
)
|
||||
if !handled || err == nil || !strings.Contains(err.Error(), "usage: diple --version") {
|
||||
t.Fatalf("handled=%t error=%v", handled, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCompletionCommandGeneratesSupportedShells(t *testing.T) {
|
||||
for _, shell := range completionShells {
|
||||
t.Run(shell, func(t *testing.T) {
|
||||
@@ -65,6 +89,7 @@ func TestCLIHelpIsGroupedAndActionable(t *testing.T) {
|
||||
"Appearance and navigation:",
|
||||
"Local state:",
|
||||
"diple completion <bash|zsh|fish>",
|
||||
"--version",
|
||||
"--repo OWNER/REPOSITORY",
|
||||
"--cache=false",
|
||||
"gh auth login",
|
||||
|
||||
Reference in New Issue
Block a user