From dc925c462705af9e61357d038b6a3f869f1f3157 Mon Sep 17 00:00:00 2001 From: Abdullah Algarni Date: Mon, 11 Feb 2019 17:39:04 +0300 Subject: [PATCH] Added a test for config checking --- codegen/config_test.go | 13 +++++++++++++ codegen/testdata/cfg/conflictedPackages.yml | 10 ++++++++++ 2 files changed, 23 insertions(+) create mode 100644 codegen/testdata/cfg/conflictedPackages.yml diff --git a/codegen/config_test.go b/codegen/config_test.go index a97b9d20f56..09a20abf54d 100644 --- a/codegen/config_test.go +++ b/codegen/config_test.go @@ -79,3 +79,16 @@ func TestReferencedPackages(t *testing.T) { }) } + +func TestConfigCheck(t *testing.T) { + t.Run("invalid config format due to conflicting package names", func(t *testing.T) { + config, err := LoadConfig("testdata/cfg/conflictedPackages.yml") + require.NoError(t, err) + + err = config.normalize() + require.NoError(t, err) + + err = config.check() + require.EqualError(t, err, "filenames exec.go and models.go are in the same directory but have different package definitions") + }) +} diff --git a/codegen/testdata/cfg/conflictedPackages.yml b/codegen/testdata/cfg/conflictedPackages.yml new file mode 100644 index 00000000000..ec6ceea515a --- /dev/null +++ b/codegen/testdata/cfg/conflictedPackages.yml @@ -0,0 +1,10 @@ +schema: + - schema.graphql +exec: + filename: generated/exec.go + package: graphql +model: + filename: generated/models.go +resolver: + filename: generated/resolver.go + type: Resolver