mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-11-10 04:54:03 -08:00
parent
39de419ed5
commit
2dc8dab25b
|
@ -4,7 +4,6 @@ import (
|
|||
"oh-my-posh/mock"
|
||||
"oh-my-posh/platform"
|
||||
"oh-my-posh/properties"
|
||||
"oh-my-posh/template"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
@ -50,7 +49,7 @@ func TestAzSegment(t *testing.T) {
|
|||
{
|
||||
Case: "Faulty template",
|
||||
ExpectedEnabled: true,
|
||||
ExpectedString: template.IncorrectTemplate,
|
||||
ExpectedString: "<.Data.Burp>: can't evaluate field Burp in type template.Data",
|
||||
Template: "{{ .Burp }}",
|
||||
HasPowerShell: true,
|
||||
},
|
||||
|
|
|
@ -4,7 +4,6 @@ import (
|
|||
"errors"
|
||||
"oh-my-posh/mock"
|
||||
"oh-my-posh/properties"
|
||||
"oh-my-posh/template"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
@ -125,7 +124,7 @@ func TestNSSegment(t *testing.T) {
|
|||
JSONResponse: `
|
||||
[{"sgv":50,"direction":"DoubleDown"}]`,
|
||||
Template: "\ue2a1 {{.Sgv}}{{.Burp}}",
|
||||
ExpectedString: template.IncorrectTemplate,
|
||||
ExpectedString: "<.Data.Burp>: can't evaluate field Burp in type template.Data",
|
||||
ExpectedEnabled: true,
|
||||
CacheTimeout: 10,
|
||||
},
|
||||
|
|
|
@ -4,7 +4,6 @@ import (
|
|||
"errors"
|
||||
"oh-my-posh/mock"
|
||||
"oh-my-posh/properties"
|
||||
"oh-my-posh/template"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
|
@ -85,7 +84,7 @@ func TestStravaSegment(t *testing.T) {
|
|||
},
|
||||
},
|
||||
Template: "{{.Ago}}{{.Burp}}",
|
||||
ExpectedString: template.IncorrectTemplate,
|
||||
ExpectedString: "<.Data.Burp>: can't evaluate field Burp in type template.Data",
|
||||
ExpectedEnabled: true,
|
||||
},
|
||||
}
|
||||
|
|
|
@ -58,7 +58,11 @@ func (t *Text) Render() (string, error) {
|
|||
err = tmpl.Execute(buffer, context)
|
||||
if err != nil {
|
||||
t.Env.Error("Render", err)
|
||||
return "", errors.New(IncorrectTemplate)
|
||||
msg := regex.FindNamedRegexMatch(`at (?P<MSG><.*)$`, err.Error())
|
||||
if len(msg) == 0 {
|
||||
return "", errors.New(IncorrectTemplate)
|
||||
}
|
||||
return "", errors.New(msg["MSG"])
|
||||
}
|
||||
text := buffer.String()
|
||||
// issue with missingkey=zero ignored for map[string]interface{}
|
||||
|
|
Loading…
Reference in a new issue