elvish/pkg/buildinfo/buildinfo_test.go
Qi Xiao b6d69d0b30 pkg/prog/progtest: Rewrite the progtest API.
The progtest package now provides a declarative framework, modelled after
pkg/eval/evaltest. Tests that use progtest are now much more concise.
2021-09-12 14:06:05 +01:00

24 lines
617 B
Go

package buildinfo
import (
"fmt"
"testing"
. "src.elv.sh/pkg/prog/progtest"
)
func TestProgram(t *testing.T) {
Test(t, Program,
ThatElvish("-version").WritesStdout(Value.Version+"\n"),
ThatElvish("-version", "-json").WritesStdout(mustToJSON(Value.Version)+"\n"),
ThatElvish("-buildinfo").WritesStdout(
fmt.Sprintf(
"Version: %v\nGo version: %v\nReproducible build: %v\n",
Value.Version, Value.GoVersion, Value.Reproducible)),
ThatElvish("-buildinfo", "-json").WritesStdout(mustToJSON(Value)+"\n"),
ThatElvish().ExitsWith(2).WritesStderr("internal error: no suitable subprogram\n"),
)
}