Files
ent/entc/load/load_test.go
Ariel Mashraki 2c8b5a65b7 entc: abandon plugins
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
2019-08-01 05:07:48 -07:00

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)
}