-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #233 from kzys/swag-file
Break dependency cycles
- 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.