leo
f129606b8f
All checks were successful
continuous-integration/drone/push Build is passing
* add handlers for signin,singup,logout... * introduce ent ORM and add user schema * add live mode, devel mode to selectively turn on features via config/flags * add templates, handle embedding moar smarter: * live mode uses live folder structure, else embedded templates are used * start using tailwindcss to style stuff * add development goodies for hot-reloading (browser-sync - bs.js) * pimp-up config.dhall with actual custom config Type (enables remote schema and local values only as needed) * add justfile (alternative to makefile for process automation)
85 lines
1.8 KiB
Go
85 lines
1.8 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package enttest
|
|
|
|
import (
|
|
"context"
|
|
|
|
"git.dotya.ml/mirre-mt/pcmt/ent"
|
|
// required by schema hooks.
|
|
_ "git.dotya.ml/mirre-mt/pcmt/ent/runtime"
|
|
|
|
"entgo.io/ent/dialect/sql/schema"
|
|
"git.dotya.ml/mirre-mt/pcmt/ent/migrate"
|
|
)
|
|
|
|
type (
|
|
// TestingT is the interface that is shared between
|
|
// testing.T and testing.B and used by enttest.
|
|
TestingT interface {
|
|
FailNow()
|
|
Error(...any)
|
|
}
|
|
|
|
// Option configures client creation.
|
|
Option func(*options)
|
|
|
|
options struct {
|
|
opts []ent.Option
|
|
migrateOpts []schema.MigrateOption
|
|
}
|
|
)
|
|
|
|
// WithOptions forwards options to client creation.
|
|
func WithOptions(opts ...ent.Option) Option {
|
|
return func(o *options) {
|
|
o.opts = append(o.opts, opts...)
|
|
}
|
|
}
|
|
|
|
// WithMigrateOptions forwards options to auto migration.
|
|
func WithMigrateOptions(opts ...schema.MigrateOption) Option {
|
|
return func(o *options) {
|
|
o.migrateOpts = append(o.migrateOpts, opts...)
|
|
}
|
|
}
|
|
|
|
func newOptions(opts []Option) *options {
|
|
o := &options{}
|
|
for _, opt := range opts {
|
|
opt(o)
|
|
}
|
|
return o
|
|
}
|
|
|
|
// Open calls ent.Open and auto-run migration.
|
|
func Open(t TestingT, driverName, dataSourceName string, opts ...Option) *ent.Client {
|
|
o := newOptions(opts)
|
|
c, err := ent.Open(driverName, dataSourceName, o.opts...)
|
|
if err != nil {
|
|
t.Error(err)
|
|
t.FailNow()
|
|
}
|
|
migrateSchema(t, c, o)
|
|
return c
|
|
}
|
|
|
|
// NewClient calls ent.NewClient and auto-run migration.
|
|
func NewClient(t TestingT, opts ...Option) *ent.Client {
|
|
o := newOptions(opts)
|
|
c := ent.NewClient(o.opts...)
|
|
migrateSchema(t, c, o)
|
|
return c
|
|
}
|
|
func migrateSchema(t TestingT, c *ent.Client, o *options) {
|
|
tables, err := schema.CopyTables(migrate.Tables)
|
|
if err != nil {
|
|
t.Error(err)
|
|
t.FailNow()
|
|
}
|
|
if err := migrate.Create(context.Background(), c.Schema, tables, o.migrateOpts...); err != nil {
|
|
t.Error(err)
|
|
t.FailNow()
|
|
}
|
|
}
|