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