Fix the dependency issue (#231)
This commit is contained in:
117
vendor/github.com/go-openapi/errors/.github/CONTRIBUTING.md
generated
vendored
117
vendor/github.com/go-openapi/errors/.github/CONTRIBUTING.md
generated
vendored
@@ -1,117 +0,0 @@
|
||||
## Contribution Guidelines
|
||||
|
||||
### Pull requests are always welcome
|
||||
|
||||
We are always thrilled to receive pull requests, and do our best to
|
||||
process them as fast as possible. Not sure if that typo is worth a pull
|
||||
request? Do it! We will appreciate it.
|
||||
|
||||
If your pull request is not accepted on the first try, don't be
|
||||
discouraged! If there's a problem with the implementation, hopefully you
|
||||
received feedback on what to improve.
|
||||
|
||||
We're trying very hard to keep go-swagger lean and focused. We don't want it
|
||||
to do everything for everybody. This means that we might decide against
|
||||
incorporating a new feature. However, there might be a way to implement
|
||||
that feature *on top of* go-swagger.
|
||||
|
||||
|
||||
### Conventions
|
||||
|
||||
Fork the repo and make changes on your fork in a feature branch:
|
||||
|
||||
- If it's a bugfix branch, name it XXX-something where XXX is the number of the
|
||||
issue
|
||||
- If it's a feature branch, create an enhancement issue to announce your
|
||||
intentions, and name it XXX-something where XXX is the number of the issue.
|
||||
|
||||
Submit unit tests for your changes. Go has a great test framework built in; use
|
||||
it! Take a look at existing tests for inspiration. Run the full test suite on
|
||||
your branch before submitting a pull request.
|
||||
|
||||
Update the documentation when creating or modifying features. Test
|
||||
your documentation changes for clarity, concision, and correctness, as
|
||||
well as a clean documentation build. See ``docs/README.md`` for more
|
||||
information on building the docs and how docs get released.
|
||||
|
||||
Write clean code. Universally formatted code promotes ease of writing, reading,
|
||||
and maintenance. Always run `gofmt -s -w file.go` on each changed file before
|
||||
committing your changes. Most editors have plugins that do this automatically.
|
||||
|
||||
Pull requests descriptions should be as clear as possible and include a
|
||||
reference to all the issues that they address.
|
||||
|
||||
Pull requests must not contain commits from other users or branches.
|
||||
|
||||
Commit messages must start with a capitalized and short summary (max. 50
|
||||
chars) written in the imperative, followed by an optional, more detailed
|
||||
explanatory text which is separated from the summary by an empty line.
|
||||
|
||||
Code review comments may be added to your pull request. Discuss, then make the
|
||||
suggested modifications and push additional commits to your feature branch. Be
|
||||
sure to post a comment after pushing. The new commits will show up in the pull
|
||||
request automatically, but the reviewers will not be notified unless you
|
||||
comment.
|
||||
|
||||
Before the pull request is merged, make sure that you squash your commits into
|
||||
logical units of work using `git rebase -i` and `git push -f`. After every
|
||||
commit the test suite should be passing. Include documentation changes in the
|
||||
same commit so that a revert would remove all traces of the feature or fix.
|
||||
|
||||
Commits that fix or close an issue should include a reference like `Closes #XXX`
|
||||
or `Fixes #XXX`, which will automatically close the issue when merged.
|
||||
|
||||
### Sign your work
|
||||
|
||||
The sign-off is a simple line at the end of the explanation for the
|
||||
patch, which certifies that you wrote it or otherwise have the right to
|
||||
pass it on as an open-source patch. The rules are pretty simple: if you
|
||||
can certify the below (from
|
||||
[developercertificate.org](http://developercertificate.org/)):
|
||||
|
||||
```
|
||||
Developer Certificate of Origin
|
||||
Version 1.1
|
||||
|
||||
Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
|
||||
660 York Street, Suite 102,
|
||||
San Francisco, CA 94110 USA
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim copies of this
|
||||
license document, but changing it is not allowed.
|
||||
|
||||
|
||||
Developer's Certificate of Origin 1.1
|
||||
|
||||
By making a contribution to this project, I certify that:
|
||||
|
||||
(a) The contribution was created in whole or in part by me and I
|
||||
have the right to submit it under the open source license
|
||||
indicated in the file; or
|
||||
|
||||
(b) The contribution is based upon previous work that, to the best
|
||||
of my knowledge, is covered under an appropriate open source
|
||||
license and I have the right under that license to submit that
|
||||
work with modifications, whether created in whole or in part
|
||||
by me, under the same open source license (unless I am
|
||||
permitted to submit under a different license), as indicated
|
||||
in the file; or
|
||||
|
||||
(c) The contribution was provided directly to me by some other
|
||||
person who certified (a), (b) or (c) and I have not modified
|
||||
it.
|
||||
|
||||
(d) I understand and agree that this project and the contribution
|
||||
are public and that a record of the contribution (including all
|
||||
personal information I submit with it, including my sign-off) is
|
||||
maintained indefinitely and may be redistributed consistent with
|
||||
this project or the open source license(s) involved.
|
||||
```
|
||||
|
||||
then you just add a line to every git commit message:
|
||||
|
||||
Signed-off-by: Joe Smith <joe@gmail.com>
|
||||
|
||||
using your real name (sorry, no pseudonyms or anonymous contributions.)
|
||||
|
||||
You can add the sign off when creating the git commit via `git commit -s`.
|
||||
2
vendor/github.com/go-openapi/errors/.gitignore
generated
vendored
2
vendor/github.com/go-openapi/errors/.gitignore
generated
vendored
@@ -1,2 +0,0 @@
|
||||
secrets.yml
|
||||
coverage.out
|
||||
12
vendor/github.com/go-openapi/errors/.travis.yml
generated
vendored
12
vendor/github.com/go-openapi/errors/.travis.yml
generated
vendored
@@ -1,12 +0,0 @@
|
||||
language: go
|
||||
go:
|
||||
- 1.7
|
||||
install:
|
||||
- go get -u github.com/stretchr/testify/assert
|
||||
script:
|
||||
- go test -v -race -cover -coverprofile=coverage.txt -covermode=atomic ./...
|
||||
after_success:
|
||||
- bash <(curl -s https://codecov.io/bash)
|
||||
notifications:
|
||||
slack:
|
||||
secure: gZGp9NaHxi7zawlXJXKY92BGeDR1x0tbIcTyU5nMKLq0fhIaiEBJEeALwZ4VgqsSv3DytSSF5mLH8fevAM3ixE6hxjKQ+lQuf7V/w3btCN1CSWgoua5LOh1kTnqZQtJuRvO4pzoJcT3bJWBsVZ07VGNVzzJEy/zAKCHFqBUCXShw7QemlLBcYWFNqveTlvDIfCzvouoLnPoXwxEpkjxe9uz/ZKZgAnup/fXjC8RFctmgCnkCyvJTk0Y/fZCsufixJrJhshBWTnlrFCzRmgNkz2d+i1Ls3+MJ5EJJ2Tx/A5S63dL49J1f9Kr0AKHADmulSy8JNzIckKwbyFMYUecrsW+Lsu9DhnVMy1jj5pKsJDLRi2iIU3fXTMWbcyQbXjbbnBO2mPdP3Tzme75y4D9fc8hUPeyqVv2BU26NEbQ7EF2pKJ93OXvci7HlwRBgdJa8j6mP2LEDClcPQW00g7N/OZe0cTOMa8L5AwiBlbArwqt9wv6YLJoTG0wpDhzWsFvbCg5bJxe28Yn3fIDD0Lk1I7iSnBbp/5gzF19jmxqvcT8tHRkDL4xfjbENFTZjA5uB4Z4pj4WSyWQILLV/Jwhe3fi9uQwdviFHfj5pnVrmNUiGSOQL672K5wl2c3E9mGwejvsu2dfEz28n7Y/FUnOpY3/cBS0n27JJaerS0zMKNLE=
|
||||
74
vendor/github.com/go-openapi/errors/CODE_OF_CONDUCT.md
generated
vendored
74
vendor/github.com/go-openapi/errors/CODE_OF_CONDUCT.md
generated
vendored
@@ -1,74 +0,0 @@
|
||||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
In the interest of fostering an open and welcoming environment, we as
|
||||
contributors and maintainers pledge to making participation in our project and
|
||||
our community a harassment-free experience for everyone, regardless of age, body
|
||||
size, disability, ethnicity, gender identity and expression, level of experience,
|
||||
nationality, personal appearance, race, religion, or sexual identity and
|
||||
orientation.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to creating a positive environment
|
||||
include:
|
||||
|
||||
* Using welcoming and inclusive language
|
||||
* Being respectful of differing viewpoints and experiences
|
||||
* Gracefully accepting constructive criticism
|
||||
* Focusing on what is best for the community
|
||||
* Showing empathy towards other community members
|
||||
|
||||
Examples of unacceptable behavior by participants include:
|
||||
|
||||
* The use of sexualized language or imagery and unwelcome sexual attention or
|
||||
advances
|
||||
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or electronic
|
||||
address, without explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a
|
||||
professional setting
|
||||
|
||||
## Our Responsibilities
|
||||
|
||||
Project maintainers are responsible for clarifying the standards of acceptable
|
||||
behavior and are expected to take appropriate and fair corrective action in
|
||||
response to any instances of unacceptable behavior.
|
||||
|
||||
Project maintainers have the right and responsibility to remove, edit, or
|
||||
reject comments, commits, code, wiki edits, issues, and other contributions
|
||||
that are not aligned to this Code of Conduct, or to ban temporarily or
|
||||
permanently any contributor for other behaviors that they deem inappropriate,
|
||||
threatening, offensive, or harmful.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies both within project spaces and in public spaces
|
||||
when an individual is representing the project or its community. Examples of
|
||||
representing a project or community include using an official project e-mail
|
||||
address, posting via an official social media account, or acting as an appointed
|
||||
representative at an online or offline event. Representation of a project may be
|
||||
further defined and clarified by project maintainers.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||
reported by contacting the project team at ivan+abuse@flanders.co.nz. All
|
||||
complaints will be reviewed and investigated and will result in a response that
|
||||
is deemed necessary and appropriate to the circumstances. The project team is
|
||||
obligated to maintain confidentiality with regard to the reporter of an incident.
|
||||
Further details of specific enforcement policies may be posted separately.
|
||||
|
||||
Project maintainers who do not follow or enforce the Code of Conduct in good
|
||||
faith may face temporary or permanent repercussions as determined by other
|
||||
members of the project's leadership.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
||||
available at [http://contributor-covenant.org/version/1/4][version]
|
||||
|
||||
[homepage]: http://contributor-covenant.org
|
||||
[version]: http://contributor-covenant.org/version/1/4/
|
||||
5
vendor/github.com/go-openapi/errors/README.md
generated
vendored
5
vendor/github.com/go-openapi/errors/README.md
generated
vendored
@@ -1,5 +0,0 @@
|
||||
# OpenAPI errors [](https://travis-ci.org/go-openapi/errors) [](https://codecov.io/gh/go-openapi/errors) [](https://slackin.goswagger.io)
|
||||
|
||||
[](https://raw.githubusercontent.com/go-openapi/errors/master/LICENSE) [](http://godoc.org/github.com/go-openapi/errors)
|
||||
|
||||
Shared errors used throughout the various libraries for the go-openapi toolkit
|
||||
97
vendor/github.com/go-openapi/errors/api_test.go
generated
vendored
97
vendor/github.com/go-openapi/errors/api_test.go
generated
vendored
@@ -1,97 +0,0 @@
|
||||
// Copyright 2015 go-swagger maintainers
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package errors
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestServeError(t *testing.T) {
|
||||
// method not allowed wins
|
||||
var err error
|
||||
err = MethodNotAllowed("GET", []string{"POST", "PUT"})
|
||||
recorder := httptest.NewRecorder()
|
||||
ServeError(recorder, nil, err)
|
||||
assert.Equal(t, http.StatusMethodNotAllowed, recorder.Code)
|
||||
assert.Equal(t, "POST,PUT", recorder.Header().Get("Allow"))
|
||||
// assert.Equal(t, "application/json", recorder.Header().Get("content-type"))
|
||||
assert.Equal(t, `{"code":405,"message":"method GET is not allowed, but [POST,PUT] are"}`, recorder.Body.String())
|
||||
|
||||
// renders status code from error when present
|
||||
err = NotFound("")
|
||||
recorder = httptest.NewRecorder()
|
||||
ServeError(recorder, nil, err)
|
||||
assert.Equal(t, http.StatusNotFound, recorder.Code)
|
||||
// assert.Equal(t, "application/json", recorder.Header().Get("content-type"))
|
||||
assert.Equal(t, `{"code":404,"message":"Not found"}`, recorder.Body.String())
|
||||
|
||||
// renders mapped status code from error when present
|
||||
err = InvalidTypeName("someType")
|
||||
recorder = httptest.NewRecorder()
|
||||
ServeError(recorder, nil, err)
|
||||
assert.Equal(t, http.StatusUnprocessableEntity, recorder.Code)
|
||||
// assert.Equal(t, "application/json", recorder.Header().Get("content-type"))
|
||||
assert.Equal(t, `{"code":601,"message":"someType is an invalid type name"}`, recorder.Body.String())
|
||||
|
||||
// defaults to internal server error
|
||||
err = fmt.Errorf("some error")
|
||||
recorder = httptest.NewRecorder()
|
||||
ServeError(recorder, nil, err)
|
||||
assert.Equal(t, http.StatusInternalServerError, recorder.Code)
|
||||
// assert.Equal(t, "application/json", recorder.Header().Get("content-type"))
|
||||
assert.Equal(t, `{"code":500,"message":"some error"}`, recorder.Body.String())
|
||||
}
|
||||
|
||||
func TestAPIErrors(t *testing.T) {
|
||||
err := New(402, "this failed %s", "yada")
|
||||
assert.Error(t, err)
|
||||
assert.EqualValues(t, 402, err.Code())
|
||||
assert.EqualValues(t, "this failed yada", err.Error())
|
||||
|
||||
err = NotFound("this failed %d", 1)
|
||||
assert.Error(t, err)
|
||||
assert.EqualValues(t, http.StatusNotFound, err.Code())
|
||||
assert.EqualValues(t, "this failed 1", err.Error())
|
||||
|
||||
err = NotFound("")
|
||||
assert.Error(t, err)
|
||||
assert.EqualValues(t, http.StatusNotFound, err.Code())
|
||||
assert.EqualValues(t, "Not found", err.Error())
|
||||
|
||||
err = NotImplemented("not implemented")
|
||||
assert.Error(t, err)
|
||||
assert.EqualValues(t, http.StatusNotImplemented, err.Code())
|
||||
assert.EqualValues(t, "not implemented", err.Error())
|
||||
|
||||
err = MethodNotAllowed("GET", []string{"POST", "PUT"})
|
||||
assert.Error(t, err)
|
||||
assert.EqualValues(t, http.StatusMethodNotAllowed, err.Code())
|
||||
assert.EqualValues(t, "method GET is not allowed, but [POST,PUT] are", err.Error())
|
||||
|
||||
err = InvalidContentType("application/saml", []string{"application/json", "application/x-yaml"})
|
||||
assert.Error(t, err)
|
||||
assert.EqualValues(t, http.StatusUnsupportedMediaType, err.Code())
|
||||
assert.EqualValues(t, "unsupported media type \"application/saml\", only [application/json application/x-yaml] are allowed", err.Error())
|
||||
|
||||
err = InvalidResponseFormat("application/saml", []string{"application/json", "application/x-yaml"})
|
||||
assert.Error(t, err)
|
||||
assert.EqualValues(t, http.StatusNotAcceptable, err.Code())
|
||||
assert.EqualValues(t, "unsupported media type requested, only [application/json application/x-yaml] are available", err.Error())
|
||||
}
|
||||
27
vendor/github.com/go-openapi/errors/auth_test.go
generated
vendored
27
vendor/github.com/go-openapi/errors/auth_test.go
generated
vendored
@@ -1,27 +0,0 @@
|
||||
// Copyright 2015 go-swagger maintainers
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package errors
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestUnauthenticated(t *testing.T) {
|
||||
err := Unauthenticated("basic")
|
||||
assert.EqualValues(t, 401, err.Code())
|
||||
assert.Equal(t, "unauthenticated for basic", err.Error())
|
||||
}
|
||||
33
vendor/github.com/go-openapi/errors/middleware_test.go
generated
vendored
33
vendor/github.com/go-openapi/errors/middleware_test.go
generated
vendored
@@ -1,33 +0,0 @@
|
||||
// Copyright 2015 go-swagger maintainers
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package errors
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestAPIVerificationFailed(t *testing.T) {
|
||||
err := &APIVerificationFailed{
|
||||
Section: "consumer",
|
||||
MissingSpecification: []string{"application/json", "application/x-yaml"},
|
||||
MissingRegistration: []string{"text/html", "application/xml"},
|
||||
}
|
||||
|
||||
expected := `missing [text/html, application/xml] consumer registrations
|
||||
missing from spec file [application/json, application/x-yaml] consumer`
|
||||
assert.Equal(t, expected, err.Error())
|
||||
}
|
||||
32
vendor/github.com/go-openapi/errors/parsing_test.go
generated
vendored
32
vendor/github.com/go-openapi/errors/parsing_test.go
generated
vendored
@@ -1,32 +0,0 @@
|
||||
// Copyright 2015 go-swagger maintainers
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package errors
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestParseError(t *testing.T) {
|
||||
err := NewParseError("Content-Type", "header", "application(", errors.New("unable to parse"))
|
||||
assert.EqualValues(t, 400, err.Code())
|
||||
assert.Equal(t, "parsing Content-Type header from \"application(\" failed, because unable to parse", err.Error())
|
||||
|
||||
err = NewParseError("Content-Type", "", "application(", errors.New("unable to parse"))
|
||||
assert.EqualValues(t, 400, err.Code())
|
||||
assert.Equal(t, "parsing Content-Type from \"application(\" failed, because unable to parse", err.Error())
|
||||
}
|
||||
284
vendor/github.com/go-openapi/errors/schema_test.go
generated
vendored
284
vendor/github.com/go-openapi/errors/schema_test.go
generated
vendored
@@ -1,284 +0,0 @@
|
||||
// Copyright 2015 go-swagger maintainers
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package errors
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestSchemaErrors(t *testing.T) {
|
||||
err := InvalidType("confirmed", "query", "boolean", nil)
|
||||
assert.Error(t, err)
|
||||
assert.EqualValues(t, InvalidTypeCode, err.Code())
|
||||
assert.Equal(t, "confirmed in query must be of type boolean", err.Error())
|
||||
|
||||
err = InvalidType("confirmed", "", "boolean", nil)
|
||||
assert.Error(t, err)
|
||||
assert.EqualValues(t, InvalidTypeCode, err.Code())
|
||||
assert.Equal(t, "confirmed must be of type boolean", err.Error())
|
||||
|
||||
err = InvalidType("confirmed", "query", "boolean", "hello")
|
||||
assert.Error(t, err)
|
||||
assert.EqualValues(t, InvalidTypeCode, err.Code())
|
||||
assert.Equal(t, "confirmed in query must be of type boolean: \"hello\"", err.Error())
|
||||
|
||||
err = InvalidType("confirmed", "query", "boolean", errors.New("hello"))
|
||||
assert.Error(t, err)
|
||||
assert.EqualValues(t, InvalidTypeCode, err.Code())
|
||||
assert.Equal(t, "confirmed in query must be of type boolean, because: hello", err.Error())
|
||||
|
||||
err = InvalidType("confirmed", "", "boolean", "hello")
|
||||
assert.Error(t, err)
|
||||
assert.EqualValues(t, InvalidTypeCode, err.Code())
|
||||
assert.Equal(t, "confirmed must be of type boolean: \"hello\"", err.Error())
|
||||
|
||||
err = InvalidType("confirmed", "", "boolean", errors.New("hello"))
|
||||
assert.Error(t, err)
|
||||
assert.EqualValues(t, InvalidTypeCode, err.Code())
|
||||
assert.Equal(t, "confirmed must be of type boolean, because: hello", err.Error())
|
||||
|
||||
err = DuplicateItems("uniques", "query")
|
||||
assert.Error(t, err)
|
||||
assert.EqualValues(t, UniqueFailCode, err.Code())
|
||||
assert.Equal(t, "uniques in query shouldn't contain duplicates", err.Error())
|
||||
|
||||
err = DuplicateItems("uniques", "")
|
||||
assert.Error(t, err)
|
||||
assert.EqualValues(t, UniqueFailCode, err.Code())
|
||||
assert.Equal(t, "uniques shouldn't contain duplicates", err.Error())
|
||||
|
||||
err = TooManyItems("something", "query", 5)
|
||||
assert.Error(t, err)
|
||||
assert.EqualValues(t, MaxItemsFailCode, err.Code())
|
||||
assert.Equal(t, "something in query should have at most 5 items", err.Error())
|
||||
|
||||
err = TooManyItems("something", "", 5)
|
||||
assert.Error(t, err)
|
||||
assert.EqualValues(t, MaxItemsFailCode, err.Code())
|
||||
assert.Equal(t, "something should have at most 5 items", err.Error())
|
||||
|
||||
err = TooFewItems("something", "", 5)
|
||||
assert.Error(t, err)
|
||||
assert.EqualValues(t, MinItemsFailCode, err.Code())
|
||||
assert.Equal(t, "something should have at least 5 items", err.Error())
|
||||
|
||||
err = ExceedsMaximumInt("something", "query", 5, false)
|
||||
assert.Error(t, err)
|
||||
assert.EqualValues(t, MaxFailCode, err.Code())
|
||||
assert.Equal(t, "something in query should be less than or equal to 5", err.Error())
|
||||
|
||||
err = ExceedsMaximumInt("something", "", 5, false)
|
||||
assert.Error(t, err)
|
||||
assert.EqualValues(t, MaxFailCode, err.Code())
|
||||
assert.Equal(t, "something should be less than or equal to 5", err.Error())
|
||||
|
||||
err = ExceedsMaximumInt("something", "query", 5, true)
|
||||
assert.Error(t, err)
|
||||
assert.EqualValues(t, MaxFailCode, err.Code())
|
||||
assert.Equal(t, "something in query should be less than 5", err.Error())
|
||||
|
||||
err = ExceedsMaximumInt("something", "", 5, true)
|
||||
assert.Error(t, err)
|
||||
assert.EqualValues(t, MaxFailCode, err.Code())
|
||||
assert.Equal(t, "something should be less than 5", err.Error())
|
||||
|
||||
err = ExceedsMaximumUint("something", "query", 5, false)
|
||||
assert.Error(t, err)
|
||||
assert.EqualValues(t, MaxFailCode, err.Code())
|
||||
assert.Equal(t, "something in query should be less than or equal to 5", err.Error())
|
||||
|
||||
err = ExceedsMaximumUint("something", "", 5, false)
|
||||
assert.Error(t, err)
|
||||
assert.EqualValues(t, MaxFailCode, err.Code())
|
||||
assert.Equal(t, "something should be less than or equal to 5", err.Error())
|
||||
|
||||
err = ExceedsMaximumUint("something", "query", 5, true)
|
||||
assert.Error(t, err)
|
||||
assert.EqualValues(t, MaxFailCode, err.Code())
|
||||
assert.Equal(t, "something in query should be less than 5", err.Error())
|
||||
|
||||
err = ExceedsMaximumUint("something", "", 5, true)
|
||||
assert.Error(t, err)
|
||||
assert.EqualValues(t, MaxFailCode, err.Code())
|
||||
assert.Equal(t, "something should be less than 5", err.Error())
|
||||
|
||||
err = ExceedsMaximum("something", "query", 5, false)
|
||||
assert.Error(t, err)
|
||||
assert.EqualValues(t, MaxFailCode, err.Code())
|
||||
assert.Equal(t, "something in query should be less than or equal to 5", err.Error())
|
||||
|
||||
err = ExceedsMaximum("something", "", 5, false)
|
||||
assert.Error(t, err)
|
||||
assert.EqualValues(t, MaxFailCode, err.Code())
|
||||
assert.Equal(t, "something should be less than or equal to 5", err.Error())
|
||||
|
||||
err = ExceedsMaximum("something", "query", 5, true)
|
||||
assert.Error(t, err)
|
||||
assert.EqualValues(t, MaxFailCode, err.Code())
|
||||
assert.Equal(t, "something in query should be less than 5", err.Error())
|
||||
|
||||
err = ExceedsMaximum("something", "", 5, true)
|
||||
assert.Error(t, err)
|
||||
assert.EqualValues(t, MaxFailCode, err.Code())
|
||||
assert.Equal(t, "something should be less than 5", err.Error())
|
||||
|
||||
err = ExceedsMinimumInt("something", "query", 5, false)
|
||||
assert.Error(t, err)
|
||||
assert.EqualValues(t, MinFailCode, err.Code())
|
||||
assert.Equal(t, "something in query should be greater than or equal to 5", err.Error())
|
||||
|
||||
err = ExceedsMinimumInt("something", "", 5, false)
|
||||
assert.Error(t, err)
|
||||
assert.EqualValues(t, MinFailCode, err.Code())
|
||||
assert.Equal(t, "something should be greater than or equal to 5", err.Error())
|
||||
|
||||
err = ExceedsMinimumInt("something", "query", 5, true)
|
||||
assert.Error(t, err)
|
||||
assert.EqualValues(t, MinFailCode, err.Code())
|
||||
assert.Equal(t, "something in query should be greater than 5", err.Error())
|
||||
|
||||
err = ExceedsMinimumInt("something", "", 5, true)
|
||||
assert.Error(t, err)
|
||||
assert.EqualValues(t, MinFailCode, err.Code())
|
||||
assert.Equal(t, "something should be greater than 5", err.Error())
|
||||
|
||||
err = ExceedsMinimumUint("something", "query", 5, false)
|
||||
assert.Error(t, err)
|
||||
assert.EqualValues(t, MinFailCode, err.Code())
|
||||
assert.Equal(t, "something in query should be greater than or equal to 5", err.Error())
|
||||
|
||||
err = ExceedsMinimumUint("something", "", 5, false)
|
||||
assert.Error(t, err)
|
||||
assert.EqualValues(t, MinFailCode, err.Code())
|
||||
assert.Equal(t, "something should be greater than or equal to 5", err.Error())
|
||||
|
||||
err = ExceedsMinimumUint("something", "query", 5, true)
|
||||
assert.Error(t, err)
|
||||
assert.EqualValues(t, MinFailCode, err.Code())
|
||||
assert.Equal(t, "something in query should be greater than 5", err.Error())
|
||||
|
||||
err = ExceedsMinimumUint("something", "", 5, true)
|
||||
assert.Error(t, err)
|
||||
assert.EqualValues(t, MinFailCode, err.Code())
|
||||
assert.Equal(t, "something should be greater than 5", err.Error())
|
||||
|
||||
err = ExceedsMinimum("something", "query", 5, false)
|
||||
assert.Error(t, err)
|
||||
assert.EqualValues(t, MinFailCode, err.Code())
|
||||
assert.Equal(t, "something in query should be greater than or equal to 5", err.Error())
|
||||
|
||||
err = ExceedsMinimum("something", "", 5, false)
|
||||
assert.Error(t, err)
|
||||
assert.EqualValues(t, MinFailCode, err.Code())
|
||||
assert.Equal(t, "something should be greater than or equal to 5", err.Error())
|
||||
|
||||
err = ExceedsMinimum("something", "query", 5, true)
|
||||
assert.Error(t, err)
|
||||
assert.EqualValues(t, MinFailCode, err.Code())
|
||||
assert.Equal(t, "something in query should be greater than 5", err.Error())
|
||||
|
||||
err = ExceedsMinimum("something", "", 5, true)
|
||||
assert.Error(t, err)
|
||||
assert.EqualValues(t, MinFailCode, err.Code())
|
||||
assert.Equal(t, "something should be greater than 5", err.Error())
|
||||
|
||||
err = NotMultipleOf("something", "query", 5)
|
||||
assert.Error(t, err)
|
||||
assert.EqualValues(t, MultipleOfFailCode, err.Code())
|
||||
assert.Equal(t, "something in query should be a multiple of 5", err.Error())
|
||||
|
||||
err = NotMultipleOf("something", "", 5)
|
||||
assert.Error(t, err)
|
||||
assert.EqualValues(t, MultipleOfFailCode, err.Code())
|
||||
assert.Equal(t, "something should be a multiple of 5", err.Error())
|
||||
|
||||
err = EnumFail("something", "query", "yada", []interface{}{"hello", "world"})
|
||||
assert.Error(t, err)
|
||||
assert.EqualValues(t, EnumFailCode, err.Code())
|
||||
assert.Equal(t, "something in query should be one of [hello world]", err.Error())
|
||||
|
||||
err = EnumFail("something", "", "yada", []interface{}{"hello", "world"})
|
||||
assert.Error(t, err)
|
||||
assert.EqualValues(t, EnumFailCode, err.Code())
|
||||
assert.Equal(t, "something should be one of [hello world]", err.Error())
|
||||
|
||||
err = Required("something", "query")
|
||||
assert.Error(t, err)
|
||||
assert.EqualValues(t, RequiredFailCode, err.Code())
|
||||
assert.Equal(t, "something in query is required", err.Error())
|
||||
|
||||
err = Required("something", "")
|
||||
assert.Error(t, err)
|
||||
assert.EqualValues(t, RequiredFailCode, err.Code())
|
||||
assert.Equal(t, "something is required", err.Error())
|
||||
|
||||
err = TooLong("something", "query", 5)
|
||||
assert.Error(t, err)
|
||||
assert.EqualValues(t, TooLongFailCode, err.Code())
|
||||
assert.Equal(t, "something in query should be at most 5 chars long", err.Error())
|
||||
|
||||
err = TooLong("something", "", 5)
|
||||
assert.Error(t, err)
|
||||
assert.EqualValues(t, TooLongFailCode, err.Code())
|
||||
assert.Equal(t, "something should be at most 5 chars long", err.Error())
|
||||
|
||||
err = TooShort("something", "query", 5)
|
||||
assert.Error(t, err)
|
||||
assert.EqualValues(t, TooShortFailCode, err.Code())
|
||||
assert.Equal(t, "something in query should be at least 5 chars long", err.Error())
|
||||
|
||||
err = TooShort("something", "", 5)
|
||||
assert.Error(t, err)
|
||||
assert.EqualValues(t, TooShortFailCode, err.Code())
|
||||
assert.Equal(t, "something should be at least 5 chars long", err.Error())
|
||||
|
||||
err = FailedPattern("something", "query", "\\d+")
|
||||
assert.Error(t, err)
|
||||
assert.EqualValues(t, PatternFailCode, err.Code())
|
||||
assert.Equal(t, "something in query should match '\\d+'", err.Error())
|
||||
|
||||
err = FailedPattern("something", "", "\\d+")
|
||||
assert.Error(t, err)
|
||||
assert.EqualValues(t, PatternFailCode, err.Code())
|
||||
assert.Equal(t, "something should match '\\d+'", err.Error())
|
||||
|
||||
err = InvalidTypeName("something")
|
||||
assert.Error(t, err)
|
||||
assert.EqualValues(t, InvalidTypeCode, err.Code())
|
||||
assert.Equal(t, "something is an invalid type name", err.Error())
|
||||
|
||||
err = AdditionalItemsNotAllowed("something", "query")
|
||||
assert.Error(t, err)
|
||||
assert.EqualValues(t, NoAdditionalItemsCode, err.Code())
|
||||
assert.Equal(t, "something in query can't have additional items", err.Error())
|
||||
|
||||
err = AdditionalItemsNotAllowed("something", "")
|
||||
assert.Error(t, err)
|
||||
assert.EqualValues(t, NoAdditionalItemsCode, err.Code())
|
||||
assert.Equal(t, "something can't have additional items", err.Error())
|
||||
|
||||
err = InvalidCollectionFormat("something", "query", "yada")
|
||||
assert.Error(t, err)
|
||||
assert.EqualValues(t, InvalidTypeCode, err.Code())
|
||||
assert.Equal(t, "the collection format \"yada\" is not supported for the query param \"something\"", err.Error())
|
||||
|
||||
err2 := CompositeValidationError()
|
||||
assert.Error(t, err2)
|
||||
assert.EqualValues(t, CompositeErrorCode, err2.Code())
|
||||
assert.Equal(t, "validation failure list", err2.Error())
|
||||
}
|
||||
Reference in New Issue
Block a user