mirror of
https://github.com/ordinary-dev/phoenix
synced 2024-09-19 03:10:29 +05:00
test: check parsing of templates
This commit is contained in:
parent
ac54a6f854
commit
76275010a8
9
Makefile
9
Makefile
|
@ -1,10 +1,13 @@
|
|||
all: fmt vet
|
||||
all: fmt test
|
||||
|
||||
fmt:
|
||||
gofmt -s -w .
|
||||
|
||||
vet:
|
||||
go vet ./...
|
||||
test:
|
||||
go test ./...
|
||||
|
||||
run:
|
||||
go run .
|
||||
|
||||
favicons:
|
||||
convert -background none assets/favicons/favicon.svg -resize 16x16 assets/favicons/favicon-16.png
|
||||
|
|
15
testutils/workingdir.go
Normal file
15
testutils/workingdir.go
Normal file
|
@ -0,0 +1,15 @@
|
|||
package testutils
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path"
|
||||
"runtime"
|
||||
)
|
||||
|
||||
// Change the current directory to the project directory.
|
||||
// Useful for tests that work with files.
|
||||
func ResetWorkingDir() error {
|
||||
_, filename, _, _ := runtime.Caller(0)
|
||||
dir := path.Join(path.Dir(filename), "..")
|
||||
return os.Chdir(dir)
|
||||
}
|
18
views/pages/templates_test.go
Normal file
18
views/pages/templates_test.go
Normal file
|
@ -0,0 +1,18 @@
|
|||
package pages
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/ordinary-dev/phoenix/testutils"
|
||||
)
|
||||
|
||||
// Check that all templates can be loaded.
|
||||
func TestLoadTemplates(t *testing.T) {
|
||||
if err := testutils.ResetWorkingDir(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if err := LoadTemplates(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue