-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This change breaks dependency cycles by - Updating go-openapi/* packages to remove go-openapi/runtime from them. Previously some of them were consuming runtime while runtime uses them. - Use swag.File as runtime.File to make the type compatible with go-openapi/validate that now uses swag.File. This fixes go-openapi/validate#143. Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com>
- Loading branch information
Showing
4 changed files
with
37 additions
and
186 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,28 @@ | ||
package runtime | ||
|
||
import ( | ||
"io" | ||
"testing" | ||
|
||
"github.com/go-openapi/spec" | ||
"github.com/go-openapi/validate" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestFileImplementsIOReader(t *testing.T) { | ||
var file interface{} = &File{} | ||
expected := "that File implements io.Reader" | ||
assert.Implements(t, new(io.Reader), file, expected) | ||
} | ||
func TestValidateFile(t *testing.T) { | ||
fileParam := spec.FileParam("f") | ||
validator := validate.NewParamValidator(fileParam, nil) | ||
|
||
result := validator.Validate("str") | ||
assert.Equal(t, 1, len(result.Errors)) | ||
assert.Equal( | ||
t, | ||
`f in formData must be of type file: "string"`, | ||
result.Errors[0].Error(), | ||
) | ||
|
||
result = validator.Validate(&File{}) | ||
assert.True(t, result.IsValid()) | ||
|
||
func TestFileImplementsIOReadCloser(t *testing.T) { | ||
var file interface{} = &File{} | ||
expected := "that File implements io.ReadCloser" | ||
assert.Implements(t, new(io.ReadCloser), file, expected) | ||
result = validator.Validate(File{}) | ||
assert.True(t, result.IsValid()) | ||
} |
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
Oops, something went wrong.