-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(47) read sha2 256 chunked (#50)
* ManifestTest > testParseQuiltURI * testFromQuiltURI * FAIL testFromChunkedURI * SHA2_256_Chunked (underscores) * [0.1.4] - 2024-08-22
- Loading branch information
Showing
5 changed files
with
205 additions
and
3 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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package com.quiltdata.quiltcore; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class EntryTest { | ||
|
||
@Test | ||
void testEnumFor() { | ||
// Arrange | ||
String name = "SHA256"; | ||
// Act | ||
Entry.HashType result = Entry.HashType.enumFor(name); | ||
// Assert | ||
assertEquals(Entry.HashType.SHA256, result); | ||
} | ||
|
||
@Test | ||
void testEnumForChunked() { | ||
// Arrange | ||
String name = "sha2-256-chunked"; | ||
// Act | ||
Entry.HashType result = Entry.HashType.enumFor(name); | ||
// Assert | ||
assertEquals(Entry.HashType.SHA2_256_Chunked, result); | ||
} | ||
|
||
@Test | ||
void testEnumForInvalid() { | ||
// Arrange | ||
String name = "SHA-512"; | ||
// Act | ||
try { | ||
Entry.HashType result = Entry.HashType.enumFor(name); | ||
fail("Expected IllegalArgumentException"); | ||
assert result != null; | ||
} catch (IllegalArgumentException e) { | ||
// Assert | ||
assertEquals("No enum constant com.quiltdata.quiltcore.Entry.HashType.SHA-512", e.getMessage()); | ||
} | ||
} | ||
|
||
} |
51 changes: 51 additions & 0 deletions
51
lib/src/test/java/com/quiltdata/quiltcore/ManifestTest.java
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,51 @@ | ||
package com.quiltdata.quiltcore; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
import org.junit.jupiter.api.Test; | ||
import java.net.URI; | ||
import java.util.Map; | ||
|
||
public class ManifestTest { | ||
|
||
@Test | ||
void testParseQuiltURI() { | ||
// Arrange | ||
String quiltURI = "quilt+s3://bkt#package=prefix/suffix@top_hash&path=file"; | ||
try { | ||
URI uri = new URI(quiltURI); | ||
Map<String, String> result = Manifest.ParseQuiltURI(uri); | ||
assertEquals("bkt", result.get("bucket")); | ||
assertEquals("prefix/suffix", result.get("package")); | ||
assertEquals("top_hash", result.get("hash")); | ||
assertEquals("latest", result.get("revision")); | ||
assertEquals("file", result.get("path")); | ||
} catch (Exception e) { | ||
fail("Failed to create URI from quiltURI", e); | ||
} | ||
} | ||
|
||
@Test | ||
void testFromQuiltURI() { | ||
// Arrange | ||
String quiltURI = "quilt+s3://quilt-example#package=examples/metadata"; | ||
try { | ||
Manifest manifest = Manifest.FromQuiltURI(quiltURI); | ||
assert manifest != null; | ||
} catch (Exception e) { | ||
fail("Failed to create URI from quiltURI", e); | ||
} | ||
} | ||
|
||
@Test | ||
void testFromChunkedURI() { | ||
// Arrange | ||
String quiltURI = "quilt+s3://udp-spec#package=nf-quilt/source"; | ||
try { | ||
Manifest manifest = Manifest.FromQuiltURI(quiltURI); | ||
assert manifest != null; | ||
} catch (Exception e) { | ||
fail("Failed to create URI from quiltURI", e); | ||
} | ||
} | ||
|
||
} |