diff --git a/tests/schema/helpers.go b/tests/schema/helpers.go index 0d2d676f..90d83492 100644 --- a/tests/schema/helpers.go +++ b/tests/schema/helpers.go @@ -68,7 +68,7 @@ func loadTestCasesInternal(t *testing.T, errors bool, parts ...string) []TestCas if !entry.IsDir() && strings.HasSuffix(entry.Name(), ".yaml") { var errorsArray []string if errors { - errorsArray = readErrors(t, filepath.Join(dir, entry.Name()+".errors")) + errorsArray = readErrors(t, filepath.Join(dir, path+".errors")) } testCases = append(testCases, TestCase{ diff --git a/tests/schema/invalid/mocks/fake/minimal.yaml b/tests/schema/invalid/mocks/fake/minimal.yaml new file mode 100644 index 00000000..83df219d --- /dev/null +++ b/tests/schema/invalid/mocks/fake/minimal.yaml @@ -0,0 +1,18 @@ +mappings: + - from: http://localhost + to: https://github.com + mocks: + - path: /path-to-mock + response: + code: 200 + fake: + type: object + property: + first-name: + type: firstname + last-name: + type: lastname + about: + type: sentence + options: + wordcount: 15 \ No newline at end of file diff --git a/tests/schema/invalid/mocks/fake/minimal.yaml.errors b/tests/schema/invalid/mocks/fake/minimal.yaml.errors new file mode 100644 index 00000000..3e6e0a46 --- /dev/null +++ b/tests/schema/invalid/mocks/fake/minimal.yaml.errors @@ -0,0 +1,4 @@ +mappings.0: Must validate one and only one schema (oneOf) +mappings.0.mocks.0.response: Must validate one and only one schema (oneOf) +mappings.0.mocks.0.response.fake: Must validate one and only one schema (oneOf) +mappings.0.mocks.0.response.fake: Additional property property is not allowed \ No newline at end of file diff --git a/tests/schema/invalid/mocks/file/minimal.yaml b/tests/schema/invalid/mocks/file/minimal.yaml new file mode 100644 index 00000000..09194817 --- /dev/null +++ b/tests/schema/invalid/mocks/file/minimal.yaml @@ -0,0 +1,8 @@ +mappings: + - from: http://localhost + to: https://github.com + mocks: + - path: /path-to-mock + response: + code: 99 + file: /path/to/file.json \ No newline at end of file diff --git a/tests/schema/invalid/mocks/file/minimal.yaml.errors b/tests/schema/invalid/mocks/file/minimal.yaml.errors new file mode 100644 index 00000000..1a7054d1 --- /dev/null +++ b/tests/schema/invalid/mocks/file/minimal.yaml.errors @@ -0,0 +1,3 @@ +mappings.0: Must validate one and only one schema (oneOf) +mappings.0.mocks.0.response: Must validate one and only one schema (oneOf) +mappings.0.mocks.0.response.code: Must be greater than or equal to 100 \ No newline at end of file diff --git a/tests/schema/invalid/mocks/raw/minimal.yaml b/tests/schema/invalid/mocks/raw/minimal.yaml new file mode 100644 index 00000000..05dcf2a4 --- /dev/null +++ b/tests/schema/invalid/mocks/raw/minimal.yaml @@ -0,0 +1,7 @@ +mappings: + - from: http://localhost + to: https://github.com + mocks: + - path: /path-to-mock + response: + raw: "Hello, World!" \ No newline at end of file diff --git a/tests/schema/invalid/mocks/raw/minimal.yaml.errors b/tests/schema/invalid/mocks/raw/minimal.yaml.errors new file mode 100644 index 00000000..0866dcc8 --- /dev/null +++ b/tests/schema/invalid/mocks/raw/minimal.yaml.errors @@ -0,0 +1,3 @@ +mappings.0: Must validate one and only one schema (oneOf) +mappings.0.mocks.0.response: Must validate one and only one schema (oneOf) +mappings.0.mocks.0.response: code is required \ No newline at end of file diff --git a/tools/schema/fakedata.go b/tools/schema/fakedata.go index bc532f1d..ddca8e6d 100644 --- a/tools/schema/fakedata.go +++ b/tools/schema/fakedata.go @@ -1,11 +1,12 @@ package main import ( + "sort" + "github.com/Jeffail/gabs" "github.com/brianvoe/gofakeit/v7" "github.com/evg4b/uncors/pkg/fakedata" "github.com/samber/lo" - "sort" ) func generateFakeDataNodes() []*gabs.Container {