Skip to content

Commit

Permalink
Added test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
evg4b committed Jun 29, 2024
1 parent 605a047 commit 2cd27d8
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 3 deletions.
3 changes: 3 additions & 0 deletions tests/schema/invalid/not-full-mapping.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
mappings:
- from: http://localhost
to:
11 changes: 10 additions & 1 deletion tests/schema/invalid_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package schema_test

import (
"github.com/evg4b/uncors/tests/schema"
"path/filepath"
"testing"

"github.com/evg4b/uncors/tests/schema"

"github.com/evg4b/uncors/testing/testutils"
"github.com/samber/lo"
"github.com/stretchr/testify/assert"
Expand All @@ -30,6 +31,14 @@ func TestInvalidJsonSchema(t *testing.T) {
"mappings: Array must have at least 1 items",
},
},
{
name: "not full mapping",
file: testdir("not-full-mapping.yaml"),
errors: []string{
"mappings.0: Must validate one and only one schema (oneOf)",
"mappings.0.to: Invalid type. Expected: string, given: null",
},
},
}

for _, testCase := range cases {
Expand Down
1 change: 0 additions & 1 deletion tests/schema/valid/minimal-valid.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
http-port: 3000
mappings:
- from: http://localhost
to: https://github.com
3 changes: 3 additions & 0 deletions tests/schema/valid/short-mapping.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
http-port: 3000
mappings:
- http://localhost: https://github.com
7 changes: 6 additions & 1 deletion tests/schema/valid_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package schema_test

import (
"github.com/evg4b/uncors/tests/schema"
"path/filepath"
"testing"

"github.com/evg4b/uncors/tests/schema"

"github.com/evg4b/uncors/testing/testutils"

"github.com/stretchr/testify/assert"
Expand All @@ -27,6 +28,10 @@ func TestValidJsonSchema(t *testing.T) {
name: "minimal valid file",
file: testdir("minimal-valid.yaml"),
},
{
name: "short mapping",
file: testdir("short-mapping.yaml"),
},
}

for _, testCase := range cases {
Expand Down

0 comments on commit 2cd27d8

Please sign in to comment.