diff options
author | satotake <doublequotation@gmail.com> | 2021-05-24 21:59:02 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-24 14:59:02 +0200 |
commit | 845a7ba4fc30c61842148d67d31d0fa3db8f40b9 (patch) | |
tree | ebe8b5c909b39ac9258e27fbc16bb1b3e3ce2d79 /hugolib/shortcode_test.go | |
parent | 10f60de89a5a53528f1e3a47a77224e5c7915e4e (diff) |
Catch incomplete shortcode error
Currently, no name shortcodes (`{{< >}}`) enter unexpected branch and
throw `BUG: template info not set`. This patch checks if shortcode has
name or not earlier and throws specific error.
Closes #6866
Diffstat (limited to 'hugolib/shortcode_test.go')
-rw-r--r-- | hugolib/shortcode_test.go | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/hugolib/shortcode_test.go b/hugolib/shortcode_test.go index 41f4eddb5..51187a003 100644 --- a/hugolib/shortcode_test.go +++ b/hugolib/shortcode_test.go @@ -65,8 +65,9 @@ title: "Title" t.Fatalf("Shortcode rendered error %s.", err) } - if err == nil && expectError { - t.Fatalf("No error from shortcode") + if expectError { + c.Assert(err, qt.ErrorMatches, expected) + return } h := b.H @@ -341,6 +342,12 @@ func TestShortcodeWrappedInPIssue(t *testing.T) { `, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", wt) } +// #6866 +func TestShortcodeIncomplete(t *testing.T) { + t.Parallel() + CheckShortCodeMatchAndError(t, `{{< >}}`, ".*shortcode has no name.*", nil, true) +} + func TestExtractShortcodes(t *testing.T) { b := newTestSitesBuilder(t).WithSimpleConfigFile() |