summaryrefslogtreecommitdiffstats
path: root/hugolib/siteJSONEncode_test.go
blob: 7c4bb48e3df69c086f8070983177a873b58b562c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package hugolib

import (
	"encoding/json"
	"fmt"
	"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)

	j, err := json.Marshal(s)
	check(t, err)
	fmt.Println("Site as JSON", string(j))

	p, err := json.Marshal(s.Pages[0])
	check(t, err)
	fmt.Println("Page as JSON", string(p))

}

func check(t *testing.T, err error) {
	if err != nil {
		t.Fatalf("Failed %s", err)
	}
}