tests

package
v0.0.0-...-fbe7d06 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 7, 2015 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AbsPath

func AbsPath(p string) (string, error)

func NewTestModelInterfaceSlice

func NewTestModelInterfaceSlice(startIndex int, count int) []interface{}

func NewTestParentInterfaceSlice

func NewTestParentInterfaceSlice(startIndex int, count int, withChildren bool) []interface{}

func TestBackend

func TestBackend(skipFlag *bool, backendBuilder func() (db.Backend, apperror.Error))

func WriteFile

func WriteFile(p string, content []byte, createDir bool) error

Types

type File

type File struct {
	Id       uint64
	TaskId   uint64
	Filename string `db:"required"`
}

type HooksModel

type HooksModel struct {
	TestModel
	CalledHooks []string `db:"-"`
	HookError   bool     `db:"-"`
}

func (*HooksModel) AfterCreate

func (h *HooksModel) AfterCreate(Backend)

func (*HooksModel) AfterDelete

func (h *HooksModel) AfterDelete(Backend)

func (*HooksModel) AfterQuery

func (h *HooksModel) AfterQuery(Backend)

func (*HooksModel) AfterUpdate

func (h *HooksModel) AfterUpdate(Backend)

func (*HooksModel) BeforeCreate

func (h *HooksModel) BeforeCreate(Backend) error

func (*HooksModel) BeforeDelete

func (h *HooksModel) BeforeDelete(Backend) error

func (*HooksModel) BeforeUpdate

func (h *HooksModel) BeforeUpdate(Backend) error

func (*HooksModel) Validate

func (h *HooksModel) Validate() error

type MarshalledData

type MarshalledData struct {
	IntVal    int
	StringVal string
}

type MarshalledModel

type MarshalledModel struct {
	Id uint64

	MapVal       map[string]interface{} `db:"marshal"`
	StructVal    MarshalledData         `db:"marshal"`
	StructPtrVal *MarshalledData        `db:"marshal"`
}

type Project

type Project struct {
	Id uint64

	Name        string `db:"required"`
	Description string

	CreatedAt time.Time
	UpdatedAt *time.Time

	// has-many with struct slice.
	Todos []Task

	// has-many with struct pointer slice
	ArchviedTodos []*Task
}

type Tag

type Tag struct {
	Id  uint64
	Tag string
}

type Task

type Task struct {
	Id uint64

	Name        string `db:"required"`
	Description string
	Priority    int

	// has-one with struct.
	Project   Project
	ProjectId uint64

	// has-one with struct pointer.
	Project2   *Project
	Project2Id *Project

	// belongs-to with struct.
	File *File

	// m2m with struct slice.
	Tags []Tag `db:"m2m"`
	// contains filtered or unexported fields
}

type TestModel

type TestModel struct {
	Id uint64

	// For inferred belongs-to
	TestParentId uint64 `db:"ignore-zero"`

	// For explicit has-one/belongs-to
	MyParent   *TestParent `db:"has-one:MyParentId:Id"`
	MyParentId uint64      `db:"ignore-zero"`

	StrVal string
	IntVal int64
}

func NewTestModel

func NewTestModel(index int) TestModel

func NewTestModelPtrSlice

func NewTestModelPtrSlice(startIndex int, count int) []*TestModel

func NewTestModelSlice

func NewTestModelSlice(startIndex int, count int) []TestModel

type TestParent

type TestParent struct {
	TestModel

	Child   TestModel `db:"has-one:ChildId:Id;auto-persist;"`
	ChildId uint64

	ChildPtr *TestModel `db:"belongs-to:Id:Id;auto-persist;"`

	ChildSlice    []TestModel
	ChildSlice2   []TestModel  `db:"belongs-to:Id:MyParentId"`
	ChildSlicePtr []*TestModel `db:"m2m"`
}

func NewTestParent

func NewTestParent(index int, withChildren bool) TestParent

func NewTestParentPtrSlice

func NewTestParentPtrSlice(startIndex int, count int, withChildren bool) []*TestParent

func NewTestParentSlice

func NewTestParentSlice(startIndex int, count int, withChildren bool) []TestParent

type ValidationsModel

type ValidationsModel struct {
	TestModel

	NotNullString string `db:"required"`
	NotNullInt    int    `db:"required"`

	ValidatedString string `db:"min:5;max:10"`
	ValidatedInt    int    `db:"min:5;max:10"`
}

func (*ValidationsModel) Collection

func (m *ValidationsModel) Collection() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL