Codebase list golang-github-jinzhu-gorm / upstream/0.0_git20151012.0.20e37a0 field_test.go
upstream/0.0_git20151012.0.20e37a0

Tree @upstream/0.0_git20151012.0.20e37a0 (Download .tar.gz)

field_test.go @upstream/0.0_git20151012.0.20e37a0raw · history · blame

package gorm_test

import (
	"testing"

	"github.com/jinzhu/gorm"
)

type CalculateField struct {
	gorm.Model
	Name     string
	Children []CalculateFieldChild
	Category CalculateFieldCategory
}

type CalculateFieldChild struct {
	gorm.Model
	CalculateFieldID uint
	Name             string
}

type CalculateFieldCategory struct {
	gorm.Model
	CalculateFieldID uint
	Name             string
}

func TestCalculateField(t *testing.T) {
	var field CalculateField
	fields := DB.NewScope(&field).Fields()
	if fields["children"].Relationship == nil || fields["category"].Relationship == nil {
		t.Errorf("Should calculate fields correctly for the first time")
	}
}