Skip to content

Commit

Permalink
refactor!: rename MemoryTarget to MemoryStore
Browse files Browse the repository at this point in the history
Signed-off-by: Shiwei Zhang <[email protected]>
  • Loading branch information
shizhMSFT committed Dec 29, 2023
1 parent 0e2f5ac commit b4b8a44
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

namespace OrasProject.Oras.Content;

public class MemoryTarget : ITarget, IPredecessorFinder
public class MemoryStore : ITarget, IPredecessorFinder
{
private readonly MemoryStorage _storage = new();
private readonly MemoryTagResolver _tagResolver = new();
Expand Down
8 changes: 4 additions & 4 deletions tests/OrasProject.Oras.Tests/CopyTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class CopyTest
[Fact]
public async Task CanCopyBetweenMemoryTargetsWithTaggedNode()
{
var sourceTarget = new MemoryTarget();
var sourceTarget = new MemoryStore();
var cancellationToken = new CancellationToken();
var blobs = new List<byte[]>();
var descs = new List<Descriptor>();
Expand Down Expand Up @@ -69,7 +69,7 @@ public async Task CanCopyBetweenMemoryTargetsWithTaggedNode()
var root = descs[3];
var reference = "foobar";
await sourceTarget.TagAsync(root, reference, cancellationToken);
var destinationTarget = new MemoryTarget();
var destinationTarget = new MemoryStore();
var gotDesc = await sourceTarget.CopyAsync(reference, destinationTarget, "", cancellationToken);
Assert.Equal(gotDesc, root);
Assert.Equal(await destinationTarget.ResolveAsync(reference, cancellationToken), root);
Expand All @@ -92,7 +92,7 @@ public async Task CanCopyBetweenMemoryTargetsWithTaggedNode()
[Fact]
public async Task CanCopyBetweenMemoryTargets()
{
var sourceTarget = new MemoryTarget();
var sourceTarget = new MemoryStore();
var cancellationToken = new CancellationToken();
var blobs = new List<byte[]>();
var descs = new List<Descriptor>();
Expand Down Expand Up @@ -129,7 +129,7 @@ public async Task CanCopyBetweenMemoryTargets()

}
var root = descs[3];
var destinationTarget = new MemoryTarget();
var destinationTarget = new MemoryStore();
await sourceTarget.CopyGraphAsync(destinationTarget, root, cancellationToken);
for (var i = 0; i < descs.Count; i++)
{
Expand Down
12 changes: 6 additions & 6 deletions tests/OrasProject.Oras.Tests/MemoryTest/MemoryTargetTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public async Task CanStoreData()
};

var reference = "foobar";
var memoryTarget = new MemoryTarget();
var memoryTarget = new MemoryStore();
var cancellationToken = new CancellationToken();
var stream = new MemoryStream(content);
await memoryTarget.PushAsync(descriptor, stream, cancellationToken);
Expand Down Expand Up @@ -75,7 +75,7 @@ public async Task ThrowsNotFoundExceptionWhenDataIsNotAvailable()
Size = content.Length
};

var memoryTarget = new MemoryTarget();
var memoryTarget = new MemoryStore();
var cancellationToken = new CancellationToken();
var contentExists = await memoryTarget.ExistsAsync(descriptor, cancellationToken);
Assert.False(contentExists);
Expand All @@ -101,7 +101,7 @@ public async Task ThrowsAlreadyExistsExceptionWhenSameDataIsPushedTwice()
Size = content.Length
};

var memoryTarget = new MemoryTarget();
var memoryTarget = new MemoryStore();
var cancellationToken = new CancellationToken();
var stream = new MemoryStream(content);
await memoryTarget.PushAsync(descriptor, stream, cancellationToken);
Expand All @@ -125,7 +125,7 @@ public async Task ThrowsAnErrorWhenABadPushOccurs()
Size = content.Length
};

var memoryTarget = new MemoryTarget();
var memoryTarget = new MemoryStore();
var cancellationToken = new CancellationToken();
var stream = new MemoryStream(wrongContent);
await Assert.ThrowsAnyAsync<Exception>(async () =>
Expand All @@ -152,7 +152,7 @@ public async Task ThrowsMismatchedDigestExceptionWhenHashInDigestIsDifferentFrom
Size = content.Length
};

var memoryTarget = new MemoryTarget();
var memoryTarget = new MemoryStore();
var cancellationToken = new CancellationToken();
var stream = new MemoryStream(wrongContent);
await Assert.ThrowsAnyAsync<MismatchedDigestException>(async () =>
Expand All @@ -168,7 +168,7 @@ await Assert.ThrowsAnyAsync<MismatchedDigestException>(async () =>
[Fact]
public async Task ShouldReturnPredecessorsOfNodes()
{
var memoryTarget = new MemoryTarget();
var memoryTarget = new MemoryStore();
var cancellationToken = new CancellationToken();
var blobs = new List<byte[]>();
var descs = new List<Descriptor>();
Expand Down
2 changes: 1 addition & 1 deletion tests/OrasProject.Oras.Tests/RemoteTest/RepositoryTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2101,7 +2101,7 @@ public async Task CopyFromRepositoryToMemory()
reg.HttpClient = CustomClient(func);
var src = await reg.Repository("source", CancellationToken.None);

var dst = new MemoryTarget();
var dst = new MemoryStore();
var tagName = "latest";
var desc = await src.CopyAsync(tagName, dst, tagName, CancellationToken.None);
}
Expand Down

0 comments on commit b4b8a44

Please sign in to comment.