mirror of
https://github.com/gohugoio/hugo.git
synced 2025-04-20 19:04:37 +00:00
Apply gofmt -s
This commit is contained in:
parent
8557e2cbb8
commit
6e1b0e0c00
7 changed files with 44 additions and 46 deletions
|
@ -63,7 +63,7 @@ func NewContent(kind, name string) (err error) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
for k, _ := range newmetadata {
|
for k := range newmetadata {
|
||||||
switch strings.ToLower(k) {
|
switch strings.ToLower(k) {
|
||||||
case "date":
|
case "date":
|
||||||
newmetadata[k] = time.Now()
|
newmetadata[k] = time.Now()
|
||||||
|
@ -73,7 +73,7 @@ func NewContent(kind, name string) (err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
caseimatch := func(m map[string]interface{}, key string) bool {
|
caseimatch := func(m map[string]interface{}, key string) bool {
|
||||||
for k, _ := range m {
|
for k := range m {
|
||||||
if strings.ToLower(k) == strings.ToLower(key) {
|
if strings.ToLower(k) == strings.ToLower(key) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,9 +59,9 @@ var shortCodeLexerTests = []shortCodeLexerTest{
|
||||||
tstLeftNoMD, tstSC1, tstRightNoMD, tstLeftNoMD, tstSCClose, tstSC1,
|
tstLeftNoMD, tstSC1, tstRightNoMD, tstLeftNoMD, tstSCClose, tstSC1,
|
||||||
{tError, 0, "unclosed shortcode"}}},
|
{tError, 0, "unclosed shortcode"}}},
|
||||||
{"Youtube id", `{{< sc1 -ziL-Q_456igdO-4 >}}`, []item{
|
{"Youtube id", `{{< sc1 -ziL-Q_456igdO-4 >}}`, []item{
|
||||||
tstLeftNoMD, tstSC1, item{tScParam, 0, "-ziL-Q_456igdO-4"}, tstRightNoMD, tstEOF}},
|
tstLeftNoMD, tstSC1, {tScParam, 0, "-ziL-Q_456igdO-4"}, tstRightNoMD, tstEOF}},
|
||||||
{"non-alphanumerics param quoted", `{{< sc1 "-ziL-.%QigdO-4" >}}`, []item{
|
{"non-alphanumerics param quoted", `{{< sc1 "-ziL-.%QigdO-4" >}}`, []item{
|
||||||
tstLeftNoMD, tstSC1, item{tScParam, 0, "-ziL-.%QigdO-4"}, tstRightNoMD, tstEOF}},
|
tstLeftNoMD, tstSC1, {tScParam, 0, "-ziL-.%QigdO-4"}, tstRightNoMD, tstEOF}},
|
||||||
|
|
||||||
{"two params", `{{< sc1 param1 param2 >}}`, []item{
|
{"two params", `{{< sc1 param1 param2 >}}`, []item{
|
||||||
tstLeftNoMD, tstSC1, tstParam1, tstParam2, tstRightNoMD, tstEOF}},
|
tstLeftNoMD, tstSC1, tstParam1, tstParam2, tstRightNoMD, tstEOF}},
|
||||||
|
@ -74,21 +74,21 @@ var shortCodeLexerTests = []shortCodeLexerTest{
|
||||||
tstLeftNoMD, tstSCClose, tstSC1, tstRightNoMD, tstEOF}},
|
tstLeftNoMD, tstSCClose, tstSC1, tstRightNoMD, tstEOF}},
|
||||||
{"nested complex", `{{< sc1 >}}ab{{% sc2 param1 %}}cd{{< sc3 >}}ef{{< /sc3 >}}gh{{% /sc2 %}}ij{{< /sc1 >}}kl`, []item{
|
{"nested complex", `{{< sc1 >}}ab{{% sc2 param1 %}}cd{{< sc3 >}}ef{{< /sc3 >}}gh{{% /sc2 %}}ij{{< /sc1 >}}kl`, []item{
|
||||||
tstLeftNoMD, tstSC1, tstRightNoMD,
|
tstLeftNoMD, tstSC1, tstRightNoMD,
|
||||||
item{tText, 0, "ab"},
|
{tText, 0, "ab"},
|
||||||
tstLeftMD, tstSC2, tstParam1, tstRightMD,
|
tstLeftMD, tstSC2, tstParam1, tstRightMD,
|
||||||
item{tText, 0, "cd"},
|
{tText, 0, "cd"},
|
||||||
tstLeftNoMD, tstSC3, tstRightNoMD,
|
tstLeftNoMD, tstSC3, tstRightNoMD,
|
||||||
item{tText, 0, "ef"},
|
{tText, 0, "ef"},
|
||||||
tstLeftNoMD, tstSCClose, tstSC3, tstRightNoMD,
|
tstLeftNoMD, tstSCClose, tstSC3, tstRightNoMD,
|
||||||
item{tText, 0, "gh"},
|
{tText, 0, "gh"},
|
||||||
tstLeftMD, tstSCClose, tstSC2, tstRightMD,
|
tstLeftMD, tstSCClose, tstSC2, tstRightMD,
|
||||||
item{tText, 0, "ij"},
|
{tText, 0, "ij"},
|
||||||
tstLeftNoMD, tstSCClose, tstSC1, tstRightNoMD,
|
tstLeftNoMD, tstSCClose, tstSC1, tstRightNoMD,
|
||||||
item{tText, 0, "kl"}, tstEOF,
|
{tText, 0, "kl"}, tstEOF,
|
||||||
}},
|
}},
|
||||||
|
|
||||||
{"two quoted params", `{{< sc1 "param nr. 1" "param nr. 2" >}}`, []item{
|
{"two quoted params", `{{< sc1 "param nr. 1" "param nr. 2" >}}`, []item{
|
||||||
tstLeftNoMD, tstSC1, item{tScParam, 0, "param nr. 1"}, item{tScParam, 0, "param nr. 2"}, tstRightNoMD, tstEOF}},
|
tstLeftNoMD, tstSC1, {tScParam, 0, "param nr. 1"}, {tScParam, 0, "param nr. 2"}, tstRightNoMD, tstEOF}},
|
||||||
{"two named params", `{{< sc1 param1="Hello World" param2="p2Val">}}`, []item{
|
{"two named params", `{{< sc1 param1="Hello World" param2="p2Val">}}`, []item{
|
||||||
tstLeftNoMD, tstSC1, tstParam1, tstVal, tstParam2, {tScParamVal, 0, "p2Val"}, tstRightNoMD, tstEOF}},
|
tstLeftNoMD, tstSC1, tstParam1, tstVal, tstParam2, {tScParamVal, 0, "p2Val"}, tstRightNoMD, tstEOF}},
|
||||||
{"escaped quotes", `{{< sc1 param1=\"Hello World\" >}}`, []item{
|
{"escaped quotes", `{{< sc1 param1=\"Hello World\" >}}`, []item{
|
||||||
|
@ -97,13 +97,13 @@ var shortCodeLexerTests = []shortCodeLexerTest{
|
||||||
tstLeftNoMD, tstSC1, tstParam1, tstRightNoMD, tstEOF}},
|
tstLeftNoMD, tstSC1, tstParam1, tstRightNoMD, tstEOF}},
|
||||||
{"escaped quotes inside escaped quotes", `{{< sc1 param1=\"Hello \"escaped\" World\" >}}`, []item{
|
{"escaped quotes inside escaped quotes", `{{< sc1 param1=\"Hello \"escaped\" World\" >}}`, []item{
|
||||||
tstLeftNoMD, tstSC1, tstParam1,
|
tstLeftNoMD, tstSC1, tstParam1,
|
||||||
item{tScParamVal, 0, `Hello `}, {tError, 0, `got positional parameter 'escaped'. Cannot mix named and positional parameters`}}},
|
{tScParamVal, 0, `Hello `}, {tError, 0, `got positional parameter 'escaped'. Cannot mix named and positional parameters`}}},
|
||||||
{"escaped quotes inside nonescaped quotes",
|
{"escaped quotes inside nonescaped quotes",
|
||||||
`{{< sc1 param1="Hello \"escaped\" World" >}}`, []item{
|
`{{< sc1 param1="Hello \"escaped\" World" >}}`, []item{
|
||||||
tstLeftNoMD, tstSC1, tstParam1, item{tScParamVal, 0, `Hello "escaped" World`}, tstRightNoMD, tstEOF}},
|
tstLeftNoMD, tstSC1, tstParam1, {tScParamVal, 0, `Hello "escaped" World`}, tstRightNoMD, tstEOF}},
|
||||||
{"escaped quotes inside nonescaped quotes in positional param",
|
{"escaped quotes inside nonescaped quotes in positional param",
|
||||||
`{{< sc1 "Hello \"escaped\" World" >}}`, []item{
|
`{{< sc1 "Hello \"escaped\" World" >}}`, []item{
|
||||||
tstLeftNoMD, tstSC1, item{tScParam, 0, `Hello "escaped" World`}, tstRightNoMD, tstEOF}},
|
tstLeftNoMD, tstSC1, {tScParam, 0, `Hello "escaped" World`}, tstRightNoMD, tstEOF}},
|
||||||
{"unterminated quote", `{{< sc1 param2="Hello World>}}`, []item{
|
{"unterminated quote", `{{< sc1 param2="Hello World>}}`, []item{
|
||||||
tstLeftNoMD, tstSC1, tstParam2, {tError, 0, "unterminated quoted string in shortcode parameter-argument: 'Hello World>}}'"}}},
|
tstLeftNoMD, tstSC1, tstParam2, {tError, 0, "unterminated quoted string in shortcode parameter-argument: 'Hello World>}}'"}}},
|
||||||
{"one named param, one not", `{{< sc1 param1="Hello World" p2 >}}`, []item{
|
{"one named param, one not", `{{< sc1 param1="Hello World" p2 >}}`, []item{
|
||||||
|
@ -119,11 +119,11 @@ var shortCodeLexerTests = []shortCodeLexerTest{
|
||||||
tstLeftNoMD, tstSC1, tstParam1,
|
tstLeftNoMD, tstSC1, tstParam1,
|
||||||
{tError, 0, "got named parameter 'param2'. Cannot mix named and positional parameters"}}},
|
{tError, 0, "got named parameter 'param2'. Cannot mix named and positional parameters"}}},
|
||||||
{"commented out", `{{</* sc1 */>}}`, []item{
|
{"commented out", `{{</* sc1 */>}}`, []item{
|
||||||
item{tText, 0, "{{<"}, item{tText, 0, " sc1 "}, item{tText, 0, ">}}"}, tstEOF}},
|
{tText, 0, "{{<"}, {tText, 0, " sc1 "}, {tText, 0, ">}}"}, tstEOF}},
|
||||||
{"commented out, missing close", `{{</* sc1 >}}`, []item{
|
{"commented out, missing close", `{{</* sc1 >}}`, []item{
|
||||||
{tError, 0, "comment must be closed"}}},
|
{tError, 0, "comment must be closed"}}},
|
||||||
{"commented out, misplaced close", `{{</* sc1 >}}*/`, []item{
|
{"commented out, misplaced close", `{{</* sc1 >}}*/`, []item{
|
||||||
item{tText, 0, "{{<"}, item{tText, 0, " sc1 >}}"}, {tError, 0, "comment ends before the right shortcode delimiter"}}},
|
{tText, 0, "{{<"}, {tText, 0, " sc1 >}}"}, {tError, 0, "comment ends before the right shortcode delimiter"}}},
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestShortcodeLexer(t *testing.T) {
|
func TestShortcodeLexer(t *testing.T) {
|
||||||
|
|
|
@ -474,38 +474,38 @@ func TestWhere(t *testing.T) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
sequence: []*map[int]string{
|
sequence: []*map[int]string{
|
||||||
&map[int]string{1: "a", 2: "m"}, &map[int]string{1: "c", 2: "d"}, &map[int]string{1: "e", 3: "m"},
|
{1: "a", 2: "m"}, {1: "c", 2: "d"}, {1: "e", 3: "m"},
|
||||||
},
|
},
|
||||||
key: 2, match: "m",
|
key: 2, match: "m",
|
||||||
expect: []*map[int]string{
|
expect: []*map[int]string{
|
||||||
&map[int]string{1: "a", 2: "m"},
|
{1: "a", 2: "m"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
sequence: []*TstX{
|
sequence: []*TstX{
|
||||||
&TstX{A: "a", B: "b"}, &TstX{A: "c", B: "d"}, &TstX{A: "e", B: "f"},
|
{A: "a", B: "b"}, {A: "c", B: "d"}, {A: "e", B: "f"},
|
||||||
},
|
},
|
||||||
key: "B", match: "f",
|
key: "B", match: "f",
|
||||||
expect: []*TstX{
|
expect: []*TstX{
|
||||||
&TstX{A: "e", B: "f"},
|
{A: "e", B: "f"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
sequence: []*TstX{
|
sequence: []*TstX{
|
||||||
&TstX{A: "a", B: "b"}, &TstX{A: "c", B: "d"}, &TstX{A: "e", B: "c"},
|
{A: "a", B: "b"}, {A: "c", B: "d"}, {A: "e", B: "c"},
|
||||||
},
|
},
|
||||||
key: "TstRp", match: "rc",
|
key: "TstRp", match: "rc",
|
||||||
expect: []*TstX{
|
expect: []*TstX{
|
||||||
&TstX{A: "c", B: "d"},
|
{A: "c", B: "d"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
sequence: []TstX{
|
sequence: []TstX{
|
||||||
TstX{A: "a", B: "b"}, TstX{A: "c", B: "d"}, TstX{A: "e", B: "c"},
|
{A: "a", B: "b"}, {A: "c", B: "d"}, {A: "e", B: "c"},
|
||||||
},
|
},
|
||||||
key: "TstRv", match: "rc",
|
key: "TstRv", match: "rc",
|
||||||
expect: []TstX{
|
expect: []TstX{
|
||||||
TstX{A: "e", B: "c"},
|
{A: "e", B: "c"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -738,19 +738,19 @@ func TestSort(t *testing.T) {
|
||||||
{map[string]int{"3": 10, "2": 20, "1": 30, "4": 40, "5": 50}, "value", "asc", []interface{}{10, 20, 30, 40, 50}},
|
{map[string]int{"3": 10, "2": 20, "1": 30, "4": 40, "5": 50}, "value", "asc", []interface{}{10, 20, 30, 40, 50}},
|
||||||
// test map sorting by field value
|
// test map sorting by field value
|
||||||
{
|
{
|
||||||
map[string]ts{"1": ts{10, 10.5, "ten"}, "2": ts{20, 20.5, "twenty"}, "3": ts{30, 30.5, "thirty"}, "4": ts{40, 40.5, "forty"}, "5": ts{50, 50.5, "fifty"}},
|
map[string]ts{"1": {10, 10.5, "ten"}, "2": {20, 20.5, "twenty"}, "3": {30, 30.5, "thirty"}, "4": {40, 40.5, "forty"}, "5": {50, 50.5, "fifty"}},
|
||||||
"MyInt",
|
"MyInt",
|
||||||
"asc",
|
"asc",
|
||||||
[]interface{}{ts{10, 10.5, "ten"}, ts{20, 20.5, "twenty"}, ts{30, 30.5, "thirty"}, ts{40, 40.5, "forty"}, ts{50, 50.5, "fifty"}},
|
[]interface{}{ts{10, 10.5, "ten"}, ts{20, 20.5, "twenty"}, ts{30, 30.5, "thirty"}, ts{40, 40.5, "forty"}, ts{50, 50.5, "fifty"}},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
map[string]ts{"1": ts{10, 10.5, "ten"}, "2": ts{20, 20.5, "twenty"}, "3": ts{30, 30.5, "thirty"}, "4": ts{40, 40.5, "forty"}, "5": ts{50, 50.5, "fifty"}},
|
map[string]ts{"1": {10, 10.5, "ten"}, "2": {20, 20.5, "twenty"}, "3": {30, 30.5, "thirty"}, "4": {40, 40.5, "forty"}, "5": {50, 50.5, "fifty"}},
|
||||||
"MyFloat",
|
"MyFloat",
|
||||||
"asc",
|
"asc",
|
||||||
[]interface{}{ts{10, 10.5, "ten"}, ts{20, 20.5, "twenty"}, ts{30, 30.5, "thirty"}, ts{40, 40.5, "forty"}, ts{50, 50.5, "fifty"}},
|
[]interface{}{ts{10, 10.5, "ten"}, ts{20, 20.5, "twenty"}, ts{30, 30.5, "thirty"}, ts{40, 40.5, "forty"}, ts{50, 50.5, "fifty"}},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
map[string]ts{"1": ts{10, 10.5, "ten"}, "2": ts{20, 20.5, "twenty"}, "3": ts{30, 30.5, "thirty"}, "4": ts{40, 40.5, "forty"}, "5": ts{50, 50.5, "fifty"}},
|
map[string]ts{"1": {10, 10.5, "ten"}, "2": {20, 20.5, "twenty"}, "3": {30, 30.5, "thirty"}, "4": {40, 40.5, "forty"}, "5": {50, 50.5, "fifty"}},
|
||||||
"MyString",
|
"MyString",
|
||||||
"asc",
|
"asc",
|
||||||
[]interface{}{ts{50, 50.5, "fifty"}, ts{40, 40.5, "forty"}, ts{10, 10.5, "ten"}, ts{30, 30.5, "thirty"}, ts{20, 20.5, "twenty"}},
|
[]interface{}{ts{50, 50.5, "fifty"}, ts{40, 40.5, "forty"}, ts{10, 10.5, "ten"}, ts{30, 30.5, "thirty"}, ts{20, 20.5, "twenty"}},
|
||||||
|
@ -786,12 +786,12 @@ func TestReturnWhenSet(t *testing.T) {
|
||||||
{[]uint{1, 2, 3}, 1, uint64(2)},
|
{[]uint{1, 2, 3}, 1, uint64(2)},
|
||||||
{[]float64{1.1, 2.2, 3.3}, 1, float64(2.2)},
|
{[]float64{1.1, 2.2, 3.3}, 1, float64(2.2)},
|
||||||
{[]string{"foo", "bar", "baz"}, 1, "bar"},
|
{[]string{"foo", "bar", "baz"}, 1, "bar"},
|
||||||
{[]TstX{TstX{A: "a", B: "b"}, TstX{A: "c", B: "d"}, TstX{A: "e", B: "f"}}, 1, ""},
|
{[]TstX{{A: "a", B: "b"}, {A: "c", B: "d"}, {A: "e", B: "f"}}, 1, ""},
|
||||||
{map[string]int{"foo": 1, "bar": 2, "baz": 3}, "bar", int64(2)},
|
{map[string]int{"foo": 1, "bar": 2, "baz": 3}, "bar", int64(2)},
|
||||||
{map[string]uint{"foo": 1, "bar": 2, "baz": 3}, "bar", uint64(2)},
|
{map[string]uint{"foo": 1, "bar": 2, "baz": 3}, "bar", uint64(2)},
|
||||||
{map[string]float64{"foo": 1.1, "bar": 2.2, "baz": 3.3}, "bar", float64(2.2)},
|
{map[string]float64{"foo": 1.1, "bar": 2.2, "baz": 3.3}, "bar", float64(2.2)},
|
||||||
{map[string]string{"foo": "FOO", "bar": "BAR", "baz": "BAZ"}, "bar", "BAR"},
|
{map[string]string{"foo": "FOO", "bar": "BAR", "baz": "BAZ"}, "bar", "BAR"},
|
||||||
{map[string]TstX{"foo": TstX{A: "a", B: "b"}, "bar": TstX{A: "c", B: "d"}, "baz": TstX{A: "e", B: "f"}}, "bar", ""},
|
{map[string]TstX{"foo": {A: "a", B: "b"}, "bar": {A: "c", B: "d"}, "baz": {A: "e", B: "f"}}, "bar", ""},
|
||||||
{(*[]string)(nil), "bar", ""},
|
{(*[]string)(nil), "bar", ""},
|
||||||
} {
|
} {
|
||||||
result := ReturnWhenSet(this.data, this.key)
|
result := ReturnWhenSet(this.data, this.key)
|
||||||
|
|
|
@ -4,8 +4,6 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func TestCutUsageMessage(t *testing.T) {
|
func TestCutUsageMessage(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
message string
|
message string
|
||||||
|
|
Loading…
Add table
Reference in a new issue