func TestDestroyPage(t *testing.T) {
	results, err := FindAll(Query())
	if err != nil || len(results) == 0 {
		t.Fatalf("pages: Destroy no page found :%s", err)
	}
	page := results[0]
	count := len(results)
	err = page.Destroy()
	if err != nil {
		t.Fatalf("pages: Destroy page failed :%s", err)
	}
	results, err = FindAll(Query())
	if err != nil {
		t.Fatalf("pages: Destroy error getting results :%s", err)
	}
	if len(results) != count-1 {
		t.Fatalf("pages: Destroy page count wrong :%d", len(results))
	}
}
Test Destroy method
package pages
import (
	"testing"
	"github.com/fragmenta/fragmenta-cms/src/lib/resource"
)
var testName = "foo"
func TestSetup(t *testing.T) {
	err := resource.SetupTestDatabase(2)
	if err != nil {
		t.Fatalf("pages: Setup db failed %s", err)
	}
}
func TestCreatePage(t *testing.T) {
	pageParams := map[string]string{
		"name":   testName,
		"status": "100",
	}
	id, err := New().Create(pageParams)
	if err != nil {
		t.Fatalf("pages: Create page failed :%s", err)
	}
	page, err := Find(id)
	if err != nil {
		t.Fatalf("pages: Create page find failed")
	}
	if page.Name != testName {
		t.Fatalf("pages: Create page name failed expected:%s got:%s", testName, page.Name)
	}
}
func TestListPage(t *testing.T) {
	results, err := FindAll(Query())
	if err != nil {
		t.Fatalf("pages: List no page found :%s", err)
	}
	if len(results) < 1 {
		t.Fatalf("pages: List no pages found :%s", err)
	}
}
func TestUpdatePage(t *testing.T) {
	page, err := FindFirst("name=?", testName)
	if err != nil {
		t.Fatalf("pages: Update no page found :%s", err)
	}
	name := "bar"
	pageParams := map[string]string{"name": name}
	err = page.Update(pageParams)
	if err != nil {
		t.Fatalf("pages: Update page failed :%s", err)
	}
	page, err = Find(page.ID)
	if err != nil {
		t.Fatalf("pages: Update page fetch failed :%s", page.Name)
	}
	if page.Name != name {
		t.Fatalf("pages: Update page failed :%s", page.Name)
	}
}
func TestQuery(t *testing.T) {
	results, err := FindAll(Published())
	if err != nil {
		t.Fatalf("pages: error getting pages :%s", err)
	}
	if len(results) == 0 {
		t.Fatalf("pages: published pages not found :%s", err)
	}
	results, err = FindAll(Query().Where("id>=? AND id <=?", 0, 100))
	if err != nil || len(results) == 0 {
		t.Fatalf("pages: no page found :%s", err)
	}
	if len(results) > 1 {
		t.Fatalf("pages: more than one page found for where :%s", err)
	}
}