feat(language): missing version info in .Error

resolves #2957
This commit is contained in:
Jan De Dobbeleer 2022-10-18 20:00:22 +02:00 committed by Jan De Dobbeleer
parent 3e23bd30dd
commit 6db3c8cfc2
3 changed files with 4 additions and 2 deletions

View file

@ -11,6 +11,7 @@ import (
const (
languageTemplate = " {{ if .Error }}{{ .Error }}{{ else }}{{ .Full }}{{ end }} "
noVersion = "NO VERSION"
)
type loadContext func()
@ -162,6 +163,7 @@ func (l *language) setVersion() error {
var err error
if command.getVersion == nil {
if !l.env.HasCommand(command.executable) {
lastError = errors.New(noVersion)
continue
}
versionStr, err = l.env.RunCommand(command.executable, command.args...)

View file

@ -83,7 +83,7 @@ func TestLanguageFilesFoundButNoCommandAndVersionAndDisplayVersion(t *testing.T)
}
lang := bootStrapLanguageTest(args)
assert.True(t, lang.Enabled())
assert.Equal(t, "", lang.Error, "unicorn is not available")
assert.Equal(t, noVersion, lang.Error, "unicorn is not available")
}
func TestLanguageFilesFoundButNoCommandAndVersionAndDontDisplayVersion(t *testing.T) {

View file

@ -29,7 +29,7 @@ func TestRuby(t *testing.T) {
{Case: "Ruby files", ExpectedString: "", ExpectedEnabled: true, FetchVersion: false, HasRubyFiles: true},
{Case: "Rakefile", ExpectedString: "", ExpectedEnabled: true, FetchVersion: false, HasRakeFile: true},
{Case: "Gemfile", ExpectedString: "", ExpectedEnabled: true, FetchVersion: false, HasGemFile: true},
{Case: "Gemfile with version", ExpectedString: "", ExpectedEnabled: true, FetchVersion: true, HasGemFile: true},
{Case: "Gemfile with version", ExpectedString: noVersion, ExpectedEnabled: true, FetchVersion: true, HasGemFile: true},
{Case: "No files with version", ExpectedString: "", ExpectedEnabled: false, FetchVersion: true},
{
Case: "Version with chruby",