-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
55001c2
commit 1c15f29
Showing
8 changed files
with
152 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: lint-revive | ||
on: | ||
push: | ||
branches: | ||
- master | ||
- main | ||
pull_request: | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
revive: | ||
name: revive | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version: stable | ||
- uses: morphy2k/revive-action@v2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package recurparse | ||
|
||
import ( | ||
"embed" | ||
"html/template" | ||
"strings" | ||
"testing" | ||
) | ||
|
||
//go:embed testdata/simple/*.txt | ||
var simple embed.FS | ||
|
||
func TestSimpleNil(t *testing.T) { | ||
tmpl, err := HTMLParseFS( | ||
nil, | ||
simple, | ||
"*.txt", | ||
) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
b := &strings.Builder{} | ||
err = tmpl.ExecuteTemplate(b, "testdata/simple/simple.txt", struct{ Foo string }{Foo: "bar"}) | ||
if err != nil { | ||
panic(err) | ||
} | ||
if b.String() != "super simple bar" { | ||
t.Error("not equal super simple bar") | ||
} | ||
|
||
} | ||
|
||
func TestSimpleExisting(t *testing.T) { | ||
existing, err := template.New("existing").Parse("existing {{.Foo}}") | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
tmpl, err := HTMLParseFS( | ||
existing, | ||
simple, | ||
"*.txt", | ||
) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
b := &strings.Builder{} | ||
err = tmpl.ExecuteTemplate(b, "testdata/simple/simple.txt", struct{ Foo string }{Foo: "bar"}) | ||
if err != nil { | ||
panic(err) | ||
} | ||
if b.String() != "super simple bar" { | ||
t.Error("not equal super simple bar") | ||
} | ||
|
||
b = &strings.Builder{} | ||
err = tmpl.ExecuteTemplate(b, "existing", struct{ Foo string }{Foo: "bar"}) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
if b.String() != "existing bar" { | ||
t.Error("not equal super simple bar") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
super simple {{.Foo}} |