-
Notifications
You must be signed in to change notification settings - Fork 234
Feat multipart file upload support #447
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
Open
Inksprout
wants to merge
18
commits into
pact-foundation:master
Choose a base branch
from
Inksprout:feat-multipart-file-upload-support
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
a268fdb
feat: adding support for multipart/form-data content type with a sing…
Inksprout 001dcbf
WIP adding multipart support
Inksprout 1fc59a8
get file path working
Inksprout 12dd92f
WIP test
Inksprout 1a95e95
test working example
Inksprout d4acbe0
working test for multipart/form-data and refactoring
Inksprout 22f05d4
include the test file
Inksprout b41dfc0
change the types
Inksprout 39b1304
change to type needed for ubuntu
Inksprout dad71c8
set the content type dynamically based on OS
Inksprout 058e67f
cleanup
Inksprout 5b5296b
refactors
Inksprout ab813e6
fix line ending issues
Inksprout 1cb75df
pass through file name for mime part
Inksprout 29d719b
Rename method and use fileInfo
Inksprout d0b9dc5
fix test after changing pact spec to v4
Inksprout 18502aa
Create Verifier test
Inksprout 3246f34
skip tests on windows and update docs
Inksprout 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 hidden or 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 hidden or 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 hidden or 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
74 changes: 74 additions & 0 deletions
74
samples/EventApi/Consumer.Tests/EventsApiConsumerTestsV3.cs
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,74 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Net; | ||
using System.Net.Http; | ||
using System.Runtime.InteropServices; | ||
using System.Threading.Tasks; | ||
using Consumer.Models; | ||
using FluentAssertions; | ||
using FluentAssertions.Extensions; | ||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Serialization; | ||
using PactNet; | ||
using PactNet.Matchers; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
namespace Consumer.Tests | ||
{ | ||
public class EventsApiConsumerTestsV3 | ||
{ | ||
private const string Token = "SomeValidAuthToken"; | ||
|
||
private readonly IPactBuilderV3 pact; | ||
|
||
public EventsApiConsumerTestsV3(ITestOutputHelper output) | ||
{ | ||
var config = new PactConfig | ||
{ | ||
PactDir = "../../../pacts/", | ||
Outputters = new[] | ||
{ | ||
new XUnitOutput(output) | ||
}, | ||
DefaultJsonSettings = new JsonSerializerSettings | ||
{ | ||
ContractResolver = new CamelCasePropertyNamesContractResolver() | ||
} | ||
}; | ||
|
||
var pact = Pact.V3("Event API ConsumerV3", "Event API", config); | ||
this.pact = pact.WithHttpInteractions(); | ||
} | ||
|
||
[SkippableFact] | ||
|
||
// Feature not supported on Windows | ||
public async Task UploadImage_WhenTheFileExists_Returns201() | ||
{ | ||
Skip.If(RuntimeInformation.IsOSPlatform(OSPlatform.Windows)); | ||
|
||
string contentType = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "application/octet-stream" : "image/jpeg"; | ||
|
||
var file = new FileInfo("test_file.jpeg"); | ||
|
||
|
||
this.pact | ||
.UponReceiving($"a request to upload a file") | ||
.WithRequest(HttpMethod.Post, $"/events/upload-file") | ||
.WithFileUpload(contentType, file, "file") | ||
.WillRespond() | ||
.WithStatus(201); | ||
|
||
await this.pact.VerifyAsync(async ctx => | ||
{ | ||
var client = new EventsApiClient(ctx.MockServerUri, Token); | ||
|
||
var result = await client.UploadFile(file); | ||
|
||
result.Should().BeEquivalentTo(HttpStatusCode.Created); | ||
}); | ||
} | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Uh oh!
There was an error while loading. Please reload this page.