mirror of
https://github.com/ent/ent.git
synced 2026-05-22 09:31:45 +03:00
Summary: Go plugin is not a good solution for both internal and external usage. It's hard to manage and maintain matching versions (both Go and external libraries), and it does not support Windows. Reviewed By: alexsn Differential Revision: D16582217 fbshipit-source-id: 81876d2c6f30bbfc16ecf9e5000f0670f2e62484
39 lines
916 B
Go
39 lines
916 B
Go
package load
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestLoad(t *testing.T) {
|
|
cfg := &Config{Path: "./testdata/valid"}
|
|
spec, err := cfg.Load()
|
|
require.NoError(t, err)
|
|
require.Len(t, spec.Schemas, 3)
|
|
require.Equal(t, "fbc/ent/entc/load/testdata/valid", spec.PkgPath)
|
|
}
|
|
|
|
func TestLoadWrongPath(t *testing.T) {
|
|
cfg := &Config{Path: "./boring"}
|
|
plg, err := cfg.Load()
|
|
require.Error(t, err)
|
|
require.Nil(t, plg)
|
|
}
|
|
|
|
func TestLoadSpecific(t *testing.T) {
|
|
cfg := &Config{Path: "./testdata/valid", Names: []string{"User"}}
|
|
spec, err := cfg.Load()
|
|
require.NoError(t, err)
|
|
require.Len(t, spec.Schemas, 1)
|
|
require.Equal(t, "User", spec.Schemas[0].Name)
|
|
require.Equal(t, "fbc/ent/entc/load/testdata/valid", spec.PkgPath)
|
|
}
|
|
|
|
func TestLoadNoSchema(t *testing.T) {
|
|
cfg := &Config{Path: "./testdata/invalid"}
|
|
schemas, err := cfg.Load()
|
|
require.Error(t, err)
|
|
require.Empty(t, schemas)
|
|
}
|