2015-05-23 06:28:01 -04:00
|
|
|
package hugolib
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Issue #1123
|
|
|
|
// Testing prevention of cyclic refs in JSON encoding
|
|
|
|
// May be smart to run with: -timeout 4000ms
|
|
|
|
func TestEncodePage(t *testing.T) {
|
|
|
|
|
|
|
|
// borrowed from menu_test.go
|
|
|
|
s := createTestSite(MENU_PAGE_SOURCES)
|
|
|
|
testSiteSetup(s, t)
|
|
|
|
|
2015-06-06 14:57:11 -04:00
|
|
|
_, err := json.Marshal(s)
|
2015-05-23 06:28:01 -04:00
|
|
|
check(t, err)
|
|
|
|
|
2015-06-06 14:57:11 -04:00
|
|
|
_, err = json.Marshal(s.Pages[0])
|
2015-05-23 06:28:01 -04:00
|
|
|
check(t, err)
|
|
|
|
}
|
|
|
|
|
|
|
|
func check(t *testing.T, err error) {
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("Failed %s", err)
|
|
|
|
}
|
|
|
|
}
|