Пример #1
0
func init() {
	SystemMetric = entities.RegisterKind("SystemMetric", _AppNamespace, home.SystemMetric{})
	Server = entities.RegisterKind("Server", _AppNamespace, home.Server{})
	SystemStats = entities.RegisterKind("SystemStats", _AppNamespace, home.SystemStats{})
	CPUStats = entities.RegisterKind("CPUStats", _AppNamespace, home.CPUStats{})
	MemoryStats = entities.RegisterKind("MemoryStats", _AppNamespace, home.MemoryStats{})
	DiskStats = entities.RegisterKind("DiskStats", _AppNamespace, home.DiskStats{})
	NetworkStats = entities.RegisterKind("NetworkStats", _AppNamespace, home.NetworkStats{})
	FileSystemStats = entities.RegisterKind("FileSystemStats", _AppNamespace, home.FileSystemStats{})
	NASDisk = entities.RegisterKind("NASDisk", _AppNamespace, home.NASDisk{})
	SMARTStats = entities.RegisterKind("SMARTStats", _AppNamespace, home.SMARTStats{})
}
Пример #2
0
func init() {
	entities.RegisterValueParser(pt.IEPGCrawlerScope(0), func(s string) (interface{}, error) {
		return pt.ParseIEPGCrawlerScope(s), nil
	})
	entities.RegisterValueParser(pt.IEPGExclusionTextType(0), func(s string) (interface{}, error) {
		return pt.ParseIEPGExclusionTextType(s), nil
	})

	Channel = entities.RegisterKind("Channel", _AppNamespace, pt.Channel{})
	Channel.BeforeSave = func(ent interface{}, req *wcg.Request) error {
		v := ent.(*pt.Channel)
		v.ID = fmt.Sprintf("%s.%s", v.CID, v.SID)
		return nil
	}

	IEPG = entities.RegisterKind("IEPG", _AppNamespace, pt.IEPG{})

	IEPGKeyword = entities.RegisterKind("IEPGKeyword", _AppNamespace, pt.IEPGKeyword{})
	IEPGKeyword.BeforeSave = func(ent interface{}, req *wcg.Request) error {
		v := ent.(*pt.IEPGKeyword)
		v.Keyword = strings.TrimSpace(v.Keyword)
		return nil
	}

	IEPGExclusion = entities.RegisterKind("IEPGExclusion", _AppNamespace, pt.IEPGExclusion{})
	MessengerNotification = entities.RegisterKind("MessengerNotification", _AppNamespace, pt.MessengerNotification{})
	EmailNotification = entities.RegisterKind("EmailNotification", _AppNamespace, pt.EmailNotification{})
}
Пример #3
0
import (
	"lib/server/entities"
	"lib/wcg"
	"lib/wcg/gae/gaetest"
	"net/url"
	"testing"
	"time"
)

type TEntity struct {
	ID        string    `json:"id" ent:"id"`
	Value     int       `json:"value" ent:"form"`
	UpdatedAt time.Time `json:"updated_at" ent:"timestamp"`
}

var testEntity = entities.RegisterKind("TestEntity", "", TEntity{})

func Test_EntityGet(t *testing.T) {
	assert := gaetest.NewAssert(t)
	router := wcg.NewRouter()
	router.GET("/api/:key.json",
		EntityGet(testEntity.Get(), "key"),
	)
	gaetest.CleanupDatastore(ts.Context)
	gaetest.FixtureFromMap(ts.Context, []map[string]interface{}{
		map[string]interface{}{"_kind": testEntity.String(), "_key": "1", "ID": "1"},
	})

	var got TEntity
	req := ts.GET("/api/1.json")
	res := req.RouteTo(router)
Пример #4
0
// RegisterImageCacheKind is to register ImageCache object kind on the namespace
func RegisterImageCacheKind(namespace string) *entities.Kind {
	return entities.RegisterKind("ImageCache", namespace, models.ImageCache{})
}