Skip to content

Commit

Permalink
Added some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
evg4b committed Nov 30, 2024
1 parent be8029e commit 478fb99
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tests/schema/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
18 changes: 18 additions & 0 deletions tests/schema/invalid/mocks/fake/minimal.yaml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions tests/schema/invalid/mocks/fake/minimal.yaml.errors
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions tests/schema/invalid/mocks/file/minimal.yaml
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions tests/schema/invalid/mocks/file/minimal.yaml.errors
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions tests/schema/invalid/mocks/raw/minimal.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
mappings:
- from: http://localhost
to: https://github.com
mocks:
- path: /path-to-mock
response:
raw: "Hello, World!"
3 changes: 3 additions & 0 deletions tests/schema/invalid/mocks/raw/minimal.yaml.errors
Original file line number Diff line number Diff line change
@@ -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
3 changes: 2 additions & 1 deletion tools/schema/fakedata.go
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down

0 comments on commit 478fb99

Please sign in to comment.