vendor: remove dep and use vndr
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
This commit is contained in:
parent
16f44674a4
commit
148e72d81e
16131 changed files with 73815 additions and 4235138 deletions
117
vendor/github.com/go-openapi/jsonreference/.github/CONTRIBUTING.md
generated
vendored
117
vendor/github.com/go-openapi/jsonreference/.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`.
|
1
vendor/github.com/go-openapi/jsonreference/.gitignore
generated
vendored
1
vendor/github.com/go-openapi/jsonreference/.gitignore
generated
vendored
|
@ -1 +0,0 @@
|
|||
secrets.yml
|
14
vendor/github.com/go-openapi/jsonreference/.travis.yml
generated
vendored
14
vendor/github.com/go-openapi/jsonreference/.travis.yml
generated
vendored
|
@ -1,14 +0,0 @@
|
|||
language: go
|
||||
go:
|
||||
- 1.7
|
||||
install:
|
||||
- go get -u github.com/stretchr/testify/assert
|
||||
- go get -u github.com/PuerkitoBio/purell
|
||||
- go get -u github.com/go-openapi/jsonpointer
|
||||
script:
|
||||
- go test -v -race -cover -coverprofile=coverage.txt -covermode=atomic ./...
|
||||
after_success:
|
||||
- bash <(curl -s https://codecov.io/bash)
|
||||
notifications:
|
||||
slack:
|
||||
secure: OpQG/36F7DSF00HLm9WZMhyqFCYYyYTsVDObW226cWiR8PWYiNfLZiSEvIzT1Gx4dDjhigKTIqcLhG34CkL5iNXDjm9Yyo2RYhQPlK8NErNqUEXuBqn4RqYHW48VGhEhOyDd4Ei0E2FN5ZbgpvHgtpkdZ6XDi64r3Ac89isP9aPHXQTuv2Jog6b4/OKKiUTftLcTIst0p4Cp3gqOJWf1wnoj+IadWiECNVQT6zb47IYjtyw6+uV8iUjTzdKcRB6Zc6b4Dq7JAg1Zd7Jfxkql3hlKp4PNlRf9Cy7y5iA3G7MLyg3FcPX5z2kmcyPt2jOTRMBWUJ5zIQpOxizAcN8WsT3WWBL5KbuYK6k0PzujrIDLqdxGpNmjkkMfDBT9cKmZpm2FdW+oZgPFJP+oKmAo4u4KJz/vjiPTXgQlN5bmrLuRMCp+AwC5wkIohTqWZVPE2TK6ZSnMYcg/W39s+RP/9mJoyryAvPSpBOLTI+biCgaUCTOAZxNTWpMFc3tPYntc41WWkdKcooZ9JA5DwfcaVFyTGQ3YXz+HvX6G1z/gW0Q/A4dBi9mj2iE1xm7tRTT+4VQ2AXFvSEI1HJpfPgYnwAtwOD1v3Qm2EUHk9sCdtEDR4wVGEPIVn44GnwFMnGKx9JWppMPYwFu3SVDdHt+E+LOlhZUply11Aa+IVrT2KUQ=
|
74
vendor/github.com/go-openapi/jsonreference/CODE_OF_CONDUCT.md
generated
vendored
74
vendor/github.com/go-openapi/jsonreference/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/
|
420
vendor/github.com/go-openapi/jsonreference/reference_test.go
generated
vendored
420
vendor/github.com/go-openapi/jsonreference/reference_test.go
generated
vendored
|
@ -1,420 +0,0 @@
|
|||
// Copyright 2013 sigu-399 ( https://github.com/sigu-399 )
|
||||
//
|
||||
// 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.
|
||||
|
||||
// author sigu-399
|
||||
// author-github https://github.com/sigu-399
|
||||
// author-mail sigu.399@gmail.com
|
||||
//
|
||||
// repository-name jsonreference
|
||||
// repository-desc An implementation of JSON Reference - Go language
|
||||
//
|
||||
// description Automated tests on package.
|
||||
//
|
||||
// created 03-03-2013
|
||||
|
||||
package jsonreference
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/go-openapi/jsonpointer"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestIsRoot(t *testing.T) {
|
||||
in := "#"
|
||||
r1, err := New(in)
|
||||
assert.NoError(t, err)
|
||||
assert.True(t, r1.IsRoot())
|
||||
|
||||
in = "#/ok"
|
||||
r1 = MustCreateRef(in)
|
||||
assert.False(t, r1.IsRoot())
|
||||
|
||||
assert.Panics(t, assert.PanicTestFunc(func() {
|
||||
MustCreateRef("%2")
|
||||
}))
|
||||
}
|
||||
|
||||
func TestFull(t *testing.T) {
|
||||
|
||||
in := "http://host/path/a/b/c#/f/a/b"
|
||||
|
||||
r1, err := New(in)
|
||||
if err != nil {
|
||||
t.Errorf("New(%v) error %s", in, err.Error())
|
||||
}
|
||||
|
||||
if in != r1.String() {
|
||||
t.Errorf("New(%v) = %v, expect %v", in, r1.String(), in)
|
||||
}
|
||||
|
||||
if r1.HasFragmentOnly != false {
|
||||
t.Errorf("New(%v)::HasFragmentOnly %v expect %v", in, r1.HasFragmentOnly, false)
|
||||
}
|
||||
|
||||
if r1.HasFullURL != true {
|
||||
t.Errorf("New(%v)::HasFullURL %v expect %v", in, r1.HasFullURL, true)
|
||||
}
|
||||
|
||||
if r1.HasURLPathOnly != false {
|
||||
t.Errorf("New(%v)::HasURLPathOnly %v expect %v", in, r1.HasURLPathOnly, false)
|
||||
}
|
||||
|
||||
if r1.HasFileScheme != false {
|
||||
t.Errorf("New(%v)::HasFileScheme %v expect %v", in, r1.HasFileScheme, false)
|
||||
}
|
||||
|
||||
if r1.GetPointer().String() != "/f/a/b" {
|
||||
t.Errorf("New(%v)::GetPointer() %v expect %v", in, r1.GetPointer().String(), "/f/a/b")
|
||||
}
|
||||
}
|
||||
|
||||
func TestFullURL(t *testing.T) {
|
||||
|
||||
in := "http://host/path/a/b/c"
|
||||
|
||||
r1, err := New(in)
|
||||
if err != nil {
|
||||
t.Errorf("New(%v) error %s", in, err.Error())
|
||||
}
|
||||
|
||||
if in != r1.String() {
|
||||
t.Errorf("New(%v) = %v, expect %v", in, r1.String(), in)
|
||||
}
|
||||
|
||||
if r1.HasFragmentOnly != false {
|
||||
t.Errorf("New(%v)::HasFragmentOnly %v expect %v", in, r1.HasFragmentOnly, false)
|
||||
}
|
||||
|
||||
if r1.HasFullURL != true {
|
||||
t.Errorf("New(%v)::HasFullURL %v expect %v", in, r1.HasFullURL, true)
|
||||
}
|
||||
|
||||
if r1.HasURLPathOnly != false {
|
||||
t.Errorf("New(%v)::HasURLPathOnly %v expect %v", in, r1.HasURLPathOnly, false)
|
||||
}
|
||||
|
||||
if r1.HasFileScheme != false {
|
||||
t.Errorf("New(%v)::HasFileScheme %v expect %v", in, r1.HasFileScheme, false)
|
||||
}
|
||||
|
||||
if r1.GetPointer().String() != "" {
|
||||
t.Errorf("New(%v)::GetPointer() %v expect %v", in, r1.GetPointer().String(), "")
|
||||
}
|
||||
}
|
||||
|
||||
func TestFragmentOnly(t *testing.T) {
|
||||
|
||||
in := "#/fragment/only"
|
||||
|
||||
r1, err := New(in)
|
||||
if err != nil {
|
||||
t.Errorf("New(%v) error %s", in, err.Error())
|
||||
}
|
||||
|
||||
if in != r1.String() {
|
||||
t.Errorf("New(%v) = %v, expect %v", in, r1.String(), in)
|
||||
}
|
||||
|
||||
if r1.HasFragmentOnly != true {
|
||||
t.Errorf("New(%v)::HasFragmentOnly %v expect %v", in, r1.HasFragmentOnly, true)
|
||||
}
|
||||
|
||||
if r1.HasFullURL != false {
|
||||
t.Errorf("New(%v)::HasFullURL %v expect %v", in, r1.HasFullURL, false)
|
||||
}
|
||||
|
||||
if r1.HasURLPathOnly != false {
|
||||
t.Errorf("New(%v)::HasURLPathOnly %v expect %v", in, r1.HasURLPathOnly, false)
|
||||
}
|
||||
|
||||
if r1.HasFileScheme != false {
|
||||
t.Errorf("New(%v)::HasFileScheme %v expect %v", in, r1.HasFileScheme, false)
|
||||
}
|
||||
|
||||
if r1.GetPointer().String() != "/fragment/only" {
|
||||
t.Errorf("New(%v)::GetPointer() %v expect %v", in, r1.GetPointer().String(), "/fragment/only")
|
||||
}
|
||||
|
||||
p, _ := jsonpointer.New(r1.referenceURL.Fragment)
|
||||
r2 := Ref{referencePointer: p, HasFragmentOnly: true}
|
||||
assert.Equal(t, r2.String(), in)
|
||||
|
||||
r3 := Ref{referencePointer: p, HasFragmentOnly: false}
|
||||
assert.Equal(t, r3.String(), in[1:])
|
||||
}
|
||||
|
||||
func TestURLPathOnly(t *testing.T) {
|
||||
|
||||
in := "/documents/document.json"
|
||||
|
||||
r1, err := New(in)
|
||||
if err != nil {
|
||||
t.Errorf("New(%v) error %s", in, err.Error())
|
||||
}
|
||||
|
||||
if in != r1.String() {
|
||||
t.Errorf("New(%v) = %v, expect %v", in, r1.String(), in)
|
||||
}
|
||||
|
||||
if r1.HasFragmentOnly != false {
|
||||
t.Errorf("New(%v)::HasFragmentOnly %v expect %v", in, r1.HasFragmentOnly, false)
|
||||
}
|
||||
|
||||
if r1.HasFullURL != false {
|
||||
t.Errorf("New(%v)::HasFullURL %v expect %v", in, r1.HasFullURL, false)
|
||||
}
|
||||
|
||||
if r1.HasURLPathOnly != true {
|
||||
t.Errorf("New(%v)::HasURLPathOnly %v expect %v", in, r1.HasURLPathOnly, true)
|
||||
}
|
||||
|
||||
if r1.HasFileScheme != false {
|
||||
t.Errorf("New(%v)::HasFileScheme %v expect %v", in, r1.HasFileScheme, false)
|
||||
}
|
||||
|
||||
if r1.GetPointer().String() != "" {
|
||||
t.Errorf("New(%v)::GetPointer() %v expect %v", in, r1.GetPointer().String(), "")
|
||||
}
|
||||
}
|
||||
|
||||
func TestURLRelativePathOnly(t *testing.T) {
|
||||
|
||||
in := "document.json"
|
||||
|
||||
r1, err := New(in)
|
||||
if err != nil {
|
||||
t.Errorf("New(%v) error %s", in, err.Error())
|
||||
}
|
||||
|
||||
if in != r1.String() {
|
||||
t.Errorf("New(%v) = %v, expect %v", in, r1.String(), in)
|
||||
}
|
||||
|
||||
if r1.HasFragmentOnly != false {
|
||||
t.Errorf("New(%v)::HasFragmentOnly %v expect %v", in, r1.HasFragmentOnly, false)
|
||||
}
|
||||
|
||||
if r1.HasFullURL != false {
|
||||
t.Errorf("New(%v)::HasFullURL %v expect %v", in, r1.HasFullURL, false)
|
||||
}
|
||||
|
||||
if r1.HasURLPathOnly != true {
|
||||
t.Errorf("New(%v)::HasURLPathOnly %v expect %v", in, r1.HasURLPathOnly, true)
|
||||
}
|
||||
|
||||
if r1.HasFileScheme != false {
|
||||
t.Errorf("New(%v)::HasFileScheme %v expect %v", in, r1.HasFileScheme, false)
|
||||
}
|
||||
|
||||
if r1.GetPointer().String() != "" {
|
||||
t.Errorf("New(%v)::GetPointer() %v expect %v", in, r1.GetPointer().String(), "")
|
||||
}
|
||||
}
|
||||
|
||||
func TestInheritsInValid(t *testing.T) {
|
||||
in1 := "http://www.test.com/doc.json"
|
||||
in2 := "#/a/b"
|
||||
|
||||
r1, _ := New(in1)
|
||||
r2 := Ref{}
|
||||
result, err := r1.Inherits(r2)
|
||||
assert.Error(t, err)
|
||||
assert.Nil(t, result)
|
||||
|
||||
r1 = Ref{}
|
||||
r2, _ = New(in2)
|
||||
result, err = r1.Inherits(r2)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, r2, *result)
|
||||
}
|
||||
|
||||
func TestInheritsValid(t *testing.T) {
|
||||
|
||||
in1 := "http://www.test.com/doc.json"
|
||||
in2 := "#/a/b"
|
||||
out := in1 + in2
|
||||
|
||||
r1, _ := New(in1)
|
||||
r2, _ := New(in2)
|
||||
|
||||
result, err := r1.Inherits(r2)
|
||||
if err != nil {
|
||||
t.Errorf("Inherits(%s,%s) error %s", r1.String(), r2.String(), err.Error())
|
||||
}
|
||||
|
||||
if result.String() != out {
|
||||
t.Errorf("Inherits(%s,%s) = %s, expect %s", r1.String(), r2.String(), result.String(), out)
|
||||
}
|
||||
|
||||
if result.GetPointer().String() != "/a/b" {
|
||||
t.Errorf("result(%v)::GetPointer() %v expect %v", result.String(), result.GetPointer().String(), "/a/b")
|
||||
}
|
||||
}
|
||||
|
||||
func TestInheritsDifferentHost(t *testing.T) {
|
||||
|
||||
in1 := "http://www.test.com/doc.json"
|
||||
in2 := "http://www.test2.com/doc.json#bla"
|
||||
|
||||
r1, _ := New(in1)
|
||||
r2, _ := New(in2)
|
||||
|
||||
result, err := r1.Inherits(r2)
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("Inherits(%s,%s) should not fail. Error: %s", r1.String(), r2.String(), err.Error())
|
||||
}
|
||||
|
||||
if result.String() != in2 {
|
||||
t.Errorf("Inherits(%s,%s) should be %s but is %s", in1, in2, in2, result)
|
||||
}
|
||||
|
||||
if result.GetPointer().String() != "" {
|
||||
t.Errorf("result(%v)::GetPointer() %v expect %v", result.String(), result.GetPointer().String(), "")
|
||||
}
|
||||
}
|
||||
|
||||
func TestFileScheme(t *testing.T) {
|
||||
|
||||
in1 := "file:///Users/mac/1.json#a"
|
||||
in2 := "file:///Users/mac/2.json#b"
|
||||
|
||||
r1, _ := New(in1)
|
||||
r2, _ := New(in2)
|
||||
|
||||
if r1.HasFragmentOnly != false {
|
||||
t.Errorf("New(%v)::HasFragmentOnly %v expect %v", in1, r1.HasFragmentOnly, false)
|
||||
}
|
||||
|
||||
if r1.HasFileScheme != true {
|
||||
t.Errorf("New(%v)::HasFileScheme %v expect %v", in1, r1.HasFileScheme, true)
|
||||
}
|
||||
|
||||
if r1.HasFullFilePath != true {
|
||||
t.Errorf("New(%v)::HasFullFilePath %v expect %v", in1, r1.HasFullFilePath, true)
|
||||
}
|
||||
|
||||
if r1.IsCanonical() != true {
|
||||
t.Errorf("New(%v)::IsCanonical %v expect %v", in1, r1.IsCanonical, true)
|
||||
}
|
||||
|
||||
result, err := r1.Inherits(r2)
|
||||
if err != nil {
|
||||
t.Errorf("Inherits(%s,%s) should not fail. Error: %s", r1.String(), r2.String(), err.Error())
|
||||
}
|
||||
if result.String() != in2 {
|
||||
t.Errorf("Inherits(%s,%s) should be %s but is %s", in1, in2, in2, result)
|
||||
}
|
||||
|
||||
if result.GetPointer().String() != "" {
|
||||
t.Errorf("result(%v)::GetPointer() %v expect %v", result.String(), result.GetPointer().String(), "")
|
||||
}
|
||||
}
|
||||
|
||||
func TestReferenceResolution(t *testing.T) {
|
||||
|
||||
// 5.4. Reference Resolution Examples
|
||||
// http://tools.ietf.org/html/rfc3986#section-5.4
|
||||
|
||||
base := "http://a/b/c/d;p?q"
|
||||
baseRef, err := New(base)
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("New(%s) failed error: %s", base, err.Error())
|
||||
}
|
||||
if baseRef.String() != base {
|
||||
t.Errorf("New(%s) %s expected %s", base, baseRef.String(), base)
|
||||
}
|
||||
|
||||
checks := []string{
|
||||
// 5.4.1. Normal Examples
|
||||
// http://tools.ietf.org/html/rfc3986#section-5.4.1
|
||||
|
||||
"g:h", "g:h",
|
||||
"g", "http://a/b/c/g",
|
||||
"./g", "http://a/b/c/g",
|
||||
"g/", "http://a/b/c/g/",
|
||||
"/g", "http://a/g",
|
||||
"//g", "http://g",
|
||||
"?y", "http://a/b/c/d;p?y",
|
||||
"g?y", "http://a/b/c/g?y",
|
||||
"#s", "http://a/b/c/d;p?q#s",
|
||||
"g#s", "http://a/b/c/g#s",
|
||||
"g?y#s", "http://a/b/c/g?y#s",
|
||||
";x", "http://a/b/c/;x",
|
||||
"g;x", "http://a/b/c/g;x",
|
||||
"g;x?y#s", "http://a/b/c/g;x?y#s",
|
||||
"", "http://a/b/c/d;p?q",
|
||||
".", "http://a/b/c/",
|
||||
"./", "http://a/b/c/",
|
||||
"..", "http://a/b/",
|
||||
"../", "http://a/b/",
|
||||
"../g", "http://a/b/g",
|
||||
"../..", "http://a/",
|
||||
"../../", "http://a/",
|
||||
"../../g", "http://a/g",
|
||||
|
||||
// 5.4.2. Abnormal Examples
|
||||
// http://tools.ietf.org/html/rfc3986#section-5.4.2
|
||||
|
||||
"../../../g", "http://a/g",
|
||||
"../../../../g", "http://a/g",
|
||||
|
||||
"/./g", "http://a/g",
|
||||
"/../g", "http://a/g",
|
||||
"g.", "http://a/b/c/g.",
|
||||
".g", "http://a/b/c/.g",
|
||||
"g..", "http://a/b/c/g..",
|
||||
"..g", "http://a/b/c/..g",
|
||||
|
||||
"./../g", "http://a/b/g",
|
||||
"./g/.", "http://a/b/c/g/",
|
||||
"g/./h", "http://a/b/c/g/h",
|
||||
"g/../h", "http://a/b/c/h",
|
||||
"g;x=1/./y", "http://a/b/c/g;x=1/y",
|
||||
"g;x=1/../y", "http://a/b/c/y",
|
||||
|
||||
"g?y/./x", "http://a/b/c/g?y/./x",
|
||||
"g?y/../x", "http://a/b/c/g?y/../x",
|
||||
"g#s/./x", "http://a/b/c/g#s/./x",
|
||||
"g#s/../x", "http://a/b/c/g#s/../x",
|
||||
|
||||
"http:g", "http:g", // for strict parsers
|
||||
//"http:g", "http://a/b/c/g", // for backward compatibility
|
||||
|
||||
}
|
||||
for i := 0; i < len(checks); i += 2 {
|
||||
child := checks[i]
|
||||
expected := checks[i+1]
|
||||
// fmt.Printf("%d: %v -> %v\n", i/2, child, expected)
|
||||
|
||||
childRef, e := New(child)
|
||||
if e != nil {
|
||||
t.Errorf("%d: New(%s) failed error: %s", i/2, child, e.Error())
|
||||
}
|
||||
|
||||
res, e := baseRef.Inherits(childRef)
|
||||
if res == nil {
|
||||
t.Errorf("%d: Inherits(%s, %s) nil not expected", i/2, base, child)
|
||||
}
|
||||
if e != nil {
|
||||
t.Errorf("%d: Inherits(%s) failed error: %s", i/2, child, e.Error())
|
||||
}
|
||||
if res.String() != expected {
|
||||
t.Errorf("%d: Inherits(%s, %s) %s expected %s", i/2, base, child, res.String(), expected)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue