Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
295613c
Add tests that verify we handle unseekable streams correctly.
carlossanlop Apr 3, 2023
d627497
Add expected data field locations for all supported formats.
carlossanlop Apr 3, 2023
018f709
Add exception message for when attempting to write an unseekable data…
carlossanlop Apr 3, 2023
9092cb4
Add seekability validation in public TarWriter entry writing methods.
carlossanlop Apr 3, 2023
6c460eb
Add TarFile stream roundtrip tests for unseekable streams.
carlossanlop Apr 4, 2023
6ea8e0f
Add missing async TarFile roundtrip tests.
carlossanlop Apr 4, 2023
f87b9e9
Support unseekable streams in TarHeader.Write.
carlossanlop Apr 4, 2023
e94fefb
Reuse and simplify the code.
carlossanlop Apr 4, 2023
15523ac
More reuse, remove unused and not needed.
carlossanlop Apr 4, 2023
5979be9
Remove TarFile.CreateFromDirectoryAsync.File.Roundtrip.cs. Submit it …
carlossanlop Apr 4, 2023
b702a44
Remove unnecessary resx comments.
carlossanlop May 23, 2023
625a619
Dedicated method for writing fields to buffer depending on the format.
carlossanlop May 23, 2023
4f702c4
Specify `Data` in name of method that expects unseekable data stream.…
carlossanlop May 23, 2023
0054f99
Delete unnecessary method.
carlossanlop May 23, 2023
2fc23de
Rename WritePadding to WriteEmptyPadding
carlossanlop May 23, 2023
d81b5a8
Rename test variables
carlossanlop May 24, 2023
796d542
Merge identical test arrays into one
carlossanlop May 24, 2023
94157b0
Invert if else to be more clear about conditions
carlossanlop May 24, 2023
1557885
remove size assign comment
carlossanlop May 24, 2023
943988b
Remove redundant debug assert
carlossanlop May 24, 2023
abff5c0
Async padding byte array creation simplification
carlossanlop May 24, 2023
66dc094
Apply suggestions from code review
adamsitnik May 25, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge identical test arrays into one
  • Loading branch information
carlossanlop committed May 24, 2023
commit 796d542f88aeb1a8f5a9552fbf7df89e1b7adffe
Original file line number Diff line number Diff line change
Expand Up @@ -554,9 +554,10 @@ public void WritingUnseekableDataStream_To_UnseekableArchiveStream_Throws(TarEnt
[InlineData(TarEntryFormat.Gnu)]
public void Write_TwoEntries_With_UnseekableDataStreams(TarEntryFormat entryFormat)
{
byte[] expectedBytes = new byte[] { 0x1, 0x2, 0x3, 0x4, 0x5 };

using MemoryStream internalDataStream1 = new();
byte[] expectedBytes1 = new byte[] { 0x1, 0x2, 0x3, 0x4, 0x5 };
internalDataStream1.Write(expectedBytes1.AsSpan());
internalDataStream1.Write(expectedBytes.AsSpan());
internalDataStream1.Position = 0;

TarEntryType fileEntryType = GetTarEntryTypeForTarEntryFormat(TarEntryType.RegularFile, entryFormat);
Expand All @@ -566,8 +567,7 @@ public void Write_TwoEntries_With_UnseekableDataStreams(TarEntryFormat entryForm
entry1.DataStream = unseekableDataStream1;

using MemoryStream internalDataStream2 = new();
byte[] expectedBytes2 = new byte[] { 0x1, 0x2, 0x3, 0x4, 0x5 };
internalDataStream2.Write(expectedBytes2.AsSpan());
internalDataStream2.Write(expectedBytes.AsSpan());
internalDataStream2.Position = 0;

using WrappedStream unseekableDataStream2 = new(internalDataStream2, canRead: true, canWrite: false, canSeek: false);
Expand All @@ -589,12 +589,12 @@ public void Write_TwoEntries_With_UnseekableDataStreams(TarEntryFormat entryForm
TarEntry readEntry = reader.GetNextEntry();
Assert.NotNull(readEntry);
readEntry.DataStream.ReadExactly(actualBytes);
Assert.Equal(expectedBytes1, actualBytes);
Assert.Equal(expectedBytes, actualBytes);

readEntry = reader.GetNextEntry();
Assert.NotNull(readEntry);
readEntry.DataStream.ReadExactly(actualBytes);
Assert.Equal(expectedBytes2, actualBytes);
Assert.Equal(expectedBytes, actualBytes);

Assert.Null(reader.GetNextEntry());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -473,9 +473,10 @@ public async Task WritingUnseekableDataStream_To_UnseekableArchiveStream_Throws_
[InlineData(TarEntryFormat.Gnu)]
public async Task Write_TwoEntries_With_UnseekableDataStreams_Async(TarEntryFormat entryFormat)
{
byte[] expectedBytes = new byte[] { 0x1, 0x2, 0x3, 0x4, 0x5 };

await using MemoryStream internalDataStream1 = new();
byte[] expectedBytes1 = new byte[] { 0x1, 0x2, 0x3, 0x4, 0x5 };
await internalDataStream1.WriteAsync(expectedBytes1.AsMemory());
await internalDataStream1.WriteAsync(expectedBytes.AsMemory());
internalDataStream1.Position = 0;

TarEntryType fileEntryType = GetTarEntryTypeForTarEntryFormat(TarEntryType.RegularFile, entryFormat);
Expand All @@ -485,8 +486,7 @@ public async Task Write_TwoEntries_With_UnseekableDataStreams_Async(TarEntryForm
entry1.DataStream = unseekableDataStream1;

await using MemoryStream internalDataStream2 = new();
byte[] expectedBytes2 = new byte[] { 0x1, 0x2, 0x3, 0x4, 0x5 };
await internalDataStream2.WriteAsync(expectedBytes2.AsMemory());
await internalDataStream2.WriteAsync(expectedBytes.AsMemory());
internalDataStream2.Position = 0;

await using WrappedStream unseekableDataStream2 = new(internalDataStream2, canRead: true, canWrite: false, canSeek: false);
Expand All @@ -508,12 +508,12 @@ public async Task Write_TwoEntries_With_UnseekableDataStreams_Async(TarEntryForm
TarEntry readEntry = await reader.GetNextEntryAsync();
Assert.NotNull(readEntry);
await readEntry.DataStream.ReadExactlyAsync(actualBytes);
Assert.Equal(expectedBytes1, actualBytes);
Assert.Equal(expectedBytes, actualBytes);

readEntry = await reader.GetNextEntryAsync();
Assert.NotNull(readEntry);
await readEntry.DataStream.ReadExactlyAsync(actualBytes);
Assert.Equal(expectedBytes2, actualBytes);
Assert.Equal(expectedBytes, actualBytes);

Assert.Null(await reader.GetNextEntryAsync());
}
Expand Down