forked from testcontainers/testcontainers-dotnet
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into feature/assert-sdterr-empty
- Loading branch information
Showing
13 changed files
with
219 additions
and
46 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
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,6 +1,6 @@ | ||
{ | ||
"sdk": { | ||
"version": "8.0.100", | ||
"version": "8.0.200", | ||
"rollForward": "latestPatch" | ||
} | ||
} |
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
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
60 changes: 60 additions & 0 deletions
60
src/Testcontainers/Configurations/Volumes/UriResourceMapping.cs
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 |
---|---|---|
@@ -0,0 +1,60 @@ | ||
namespace DotNet.Testcontainers.Configurations | ||
{ | ||
using System; | ||
using System.Net.Http; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
/// <inheritdoc cref="IResourceMapping" /> | ||
internal sealed class UriResourceMapping : IResourceMapping | ||
{ | ||
private readonly Uri _uri; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="UriResourceMapping" /> class. | ||
/// </summary> | ||
/// <param name="uri">The URL of the file to download.</param> | ||
/// <param name="containerPath">The absolute path of the file to map in the container.</param> | ||
/// <param name="fileMode">The POSIX file mode permission.</param> | ||
public UriResourceMapping(Uri uri, string containerPath, UnixFileModes fileMode) | ||
{ | ||
_uri = uri; | ||
Type = MountType.Bind; | ||
Source = uri.AbsoluteUri; | ||
Target = containerPath; | ||
FileMode = fileMode; | ||
AccessMode = AccessMode.ReadOnly; | ||
} | ||
|
||
/// <inheritdoc /> | ||
public MountType Type { get; } | ||
|
||
/// <inheritdoc /> | ||
public AccessMode AccessMode { get; } | ||
|
||
/// <inheritdoc /> | ||
public string Source { get; } | ||
|
||
/// <inheritdoc /> | ||
public string Target { get; } | ||
|
||
/// <inheritdoc /> | ||
public UnixFileModes FileMode { get; } | ||
|
||
/// <inheritdoc /> | ||
public Task CreateAsync(CancellationToken ct = default) => Task.CompletedTask; | ||
|
||
/// <inheritdoc /> | ||
public Task DeleteAsync(CancellationToken ct = default) => Task.CompletedTask; | ||
|
||
/// <inheritdoc /> | ||
public async Task<byte[]> GetAllBytesAsync(CancellationToken ct = default) | ||
{ | ||
using (var httpClient = new HttpClient()) | ||
{ | ||
return await httpClient.GetByteArrayAsync(_uri) | ||
.ConfigureAwait(false); | ||
} | ||
} | ||
} | ||
} |
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
Oops, something went wrong.