mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-07 20:30:36 -05:00
hugolib: Adjust error test to make it pass on Go tip
This commit is contained in:
parent
2d7709d155
commit
acc14b4646
1 changed files with 11 additions and 1 deletions
|
@ -3,6 +3,7 @@ package hugolib
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
@ -199,14 +200,23 @@ func TestSiteBuildErrors(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
// See https://github.com/gohugoio/hugo/issues/5327
|
||||||
name: "Panic in template Execute",
|
name: "Panic in template Execute",
|
||||||
fileType: single,
|
fileType: single,
|
||||||
fileFixer: func(content string) string {
|
fileFixer: func(content string) string {
|
||||||
return strings.Replace(content, ".Title", ".Parent.Parent.Parent", 1)
|
return strings.Replace(content, ".Title", ".Parent.Parent.Parent", 1)
|
||||||
},
|
},
|
||||||
|
|
||||||
assertBuildError: func(a testSiteBuildErrorAsserter, err error) {
|
assertBuildError: func(a testSiteBuildErrorAsserter, err error) {
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
assert.Contains(err.Error(), `execute of template failed: panic in Execute`)
|
// This is fixed in latest Go source
|
||||||
|
if strings.Contains(runtime.Version(), "devel") {
|
||||||
|
fe := a.getFileError(err)
|
||||||
|
assert.Equal(5, fe.LineNumber)
|
||||||
|
assert.Equal(21, fe.ColumnNumber)
|
||||||
|
} else {
|
||||||
|
assert.Contains(err.Error(), `execute of template failed: panic in Execute`)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue