forked from oras-project/oras-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLayerTest.java
More file actions
52 lines (45 loc) · 1.58 KB
/
LayerTest.java
File metadata and controls
52 lines (45 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package land.oras;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
public class LayerTest {
@Test
void shouldReadLayer() {
String json = sampleLayer();
Layer layer = Layer.fromJson(json);
assertEquals("application/vnd.oci.image.layer.v1.tar+gzip", layer.getMediaType());
assertEquals("sha256:abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890", layer.getDigest());
assertEquals(32654, layer.getSize());
assertEquals(json, layer.toJson());
}
@Test
void shouldHaveEmptyLayer() {
String json = emptyLayer();
assertEquals(Layer.fromJson(json).toJson(), Layer.empty().toJson());
}
private String emptyLayer() {
return """
{
"mediaType": "application/vnd.oci.empty.v1+json",
"digest": "sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a",
"size": 2,
"data": "e30=",
"annotations": {}
}
""";
}
/**
* A sample manifest
* @return The manifest
*/
private String sampleLayer() {
return Layer.fromJson(
"""
{
"mediaType": "application/vnd.oci.image.layer.v1.tar+gzip",
"digest": "sha256:abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890",
"size": 32654
}
""")
.toJson();
}
}