-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fixed parsing of value only conditions
- Loading branch information
1 parent
03cd5ce
commit 543617c
Showing
4 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package criterion_test | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/speakeasy-api/openapi/arazzo/criterion" | ||
"github.com/speakeasy-api/openapi/arazzo/expression" | ||
"github.com/speakeasy-api/openapi/pointer" | ||
"github.com/speakeasy-api/openapi/validation" | ||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestCriterion_Validate_Success(t *testing.T) { | ||
type args struct { | ||
c *criterion.Criterion | ||
opts []validation.Option | ||
} | ||
tests := []struct { | ||
name string | ||
args args | ||
}{ | ||
{ | ||
name: "successfully validate criterion with empty json object condition", | ||
args: args{ | ||
c: &criterion.Criterion{ | ||
Context: pointer.From(expression.Expression("$response.body")), | ||
Type: criterion.CriterionTypeUnion{ | ||
Type: pointer.From(criterion.CriterionTypeSimple), | ||
}, | ||
Condition: ` | ||
[ | ||
{} | ||
]`, | ||
}, | ||
}, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
err := tt.args.c.Sync(context.Background()) | ||
require.NoError(t, err) | ||
errs := tt.args.c.Validate(tt.args.opts...) | ||
assert.Empty(t, errs) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters