summaryrefslogtreecommitdiffstats
path: root/hugolib/shortcode_test.go
diff options
context:
space:
mode:
authorsatotake <doublequotation@gmail.com>2021-05-24 21:59:02 +0900
committerGitHub <noreply@github.com>2021-05-24 14:59:02 +0200
commit845a7ba4fc30c61842148d67d31d0fa3db8f40b9 (patch)
treeebe8b5c909b39ac9258e27fbc16bb1b3e3ce2d79 /hugolib/shortcode_test.go
parent10f60de89a5a53528f1e3a47a77224e5c7915e4e (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.go11
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()