github.com/tommi2day/pwcli@v0.0.0-20240317203041-4d1177a5ab91/cmd/version_test.go (about) 1 package cmd 2 3 import ( 4 "testing" 5 6 "github.com/tommi2day/gomodules/common" 7 8 "github.com/tommi2day/pwcli/test" 9 10 "github.com/stretchr/testify/assert" 11 ) 12 13 func TestVersion(t *testing.T) { 14 var err error 15 var out = "" 16 test.Testinit(t) 17 t.Run("Version func", func(t *testing.T) { 18 actual := GetVersion(false) 19 assert.NotEmpty(t, actual, "GetVersion should not be empty") 20 assert.Containsf(t, actual, configName, "GetVersion should contain %s", configName) 21 t.Logf(actual) 22 }) 23 t.Run("Version cmd", func(t *testing.T) { 24 args := []string{ 25 "version", 26 "--debug", 27 "--unit-test", 28 } 29 out, err = common.CmdRun(RootCmd, args) 30 assert.NoErrorf(t, err, "version command should not return an error:%s", err) 31 assert.NotEmpty(t, out, "version command should not return an empty string") 32 assert.Containsf(t, out, configName, "version command should contain %s", configName) 33 t.Logf(out) 34 }) 35 }