-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow to pass and override default hard coded api version #274
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
ff1b8db
Add change which allows to pass and override default hard coded api v…
vbauzys 1666e87
Add back function to be back compatible
vbauzys 5fd40cb
Improve docs
vbauzys a4a3f60
Add changelog
vbauzys 398d990
Improve docs and changelog
vbauzys 1ae3d74
Improve docs
vbauzys 4b22e8b
Add test
vbauzys 7d62c82
Merge branch 'master' into api-version-override
vbauzys 448b61f
Add directive
vbauzys dd83fc4
Improved test
vbauzys 4c4f580
Merge branch 'master' into api-version-override
vbauzys fdedb01
Fixes
vbauzys File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
// +build api functional ALL | ||
|
||
/* | ||
* Copyright 2018 VMware, Inc. All rights reserved. Licensed under the Apache v2 License. | ||
*/ | ||
|
@@ -8,8 +10,11 @@ package govcd | |
|
||
import ( | ||
"fmt" | ||
"net/http" | ||
"os" | ||
"testing" | ||
|
||
. "gopkg.in/check.v1" | ||
) | ||
|
||
var testingTags = make(map[string]string) | ||
|
@@ -95,3 +100,33 @@ func TestTags(t *testing.T) { | |
showTags() | ||
} | ||
} | ||
|
||
// Test_NewRequestWitNotEncodedParamsWithApiVersion verifies that api version override works | ||
func (vcd *TestVCD) Test_NewRequestWitNotEncodedParamsWithApiVersion(check *C) { | ||
fmt.Printf("Running: %s\n", check.TestName()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Double check the outputs as they are missing new lines. Heres' how it looks.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok. This is fine as it is as planned. |
||
queryUlr := vcd.client.Client.VCDHREF | ||
queryUlr.Path += "/query" | ||
|
||
apiVersion, err := vcd.client.Client.maxSupportedVersion() | ||
check.Assert(err, IsNil) | ||
|
||
req := vcd.client.Client.NewRequestWitNotEncodedParamsWithApiVersion(nil, map[string]string{"type": "media", | ||
"filter": "name==any"}, http.MethodGet, queryUlr, nil, apiVersion) | ||
|
||
resp, err := checkResp(vcd.client.Client.Http.Do(req)) | ||
check.Assert(err, IsNil) | ||
|
||
check.Assert(resp.Header.Get("Content-Type"), Equals, "application/vnd.vmware.vcloud.query.records+xml;version="+apiVersion) | ||
|
||
// Repeats the call without API version change | ||
req = vcd.client.Client.NewRequestWitNotEncodedParams(nil, map[string]string{"type": "media", | ||
"filter": "name==any"}, http.MethodGet, queryUlr, nil) | ||
|
||
resp, err = checkResp(vcd.client.Client.Http.Do(req)) | ||
check.Assert(err, IsNil) | ||
|
||
// Checks that the regularAPI version was not affected by the previous call | ||
check.Assert(resp.Header.Get("Content-Type"), Equals, "application/vnd.vmware.vcloud.query.records+xml;version="+vcd.client.Client.APIVersion) | ||
|
||
fmt.Printf("Test: %s run with api Version: %s\n", check.TestName(), apiVersion) | ||
} |
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to see a few tests for the new functions, to make sure that:
Execute*
methods are not affected.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you share your idea how to test that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's a possible way:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two more ideas:
or
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
first option could be valid with on specific vCD version or I have to find valid for all versions, which is lottery
I'll check possibility with response headers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test added