Skip to content

Commit f19a42e

Browse files
committed
Adding unit test for runtime spec
Signed-off-by: Navid Yaghoobi <navidys@fedoraproject.org>
1 parent 8d8ec97 commit f19a42e

3 files changed

Lines changed: 24 additions & 1 deletion

File tree

tests/image/define_os.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ test "image define OS jsonParse" {
371371
// Other
372372
var osOther = std.json.Scanner.initCompleteInput(
373373
testing.allocator,
374-
"\"unknown\"",
374+
"\"other\"",
375375
);
376376

377377
defer osOther.deinit();

tests/lib.zig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ test {
77
_ = @import("image/define_os.zig");
88
_ = @import("image/define_arch.zig");
99
_ = @import("image/define_media_type.zig");
10+
_ = @import("runtime/config.zig");
1011
}

tests/runtime/config.zig

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const std = @import("std");
2+
const utils = @import("../utils.zig");
3+
const ocispec = @import("ocispec");
4+
const runtime = ocispec.runtime;
5+
const testing = std.testing;
6+
7+
test "runtime config" {
8+
var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
9+
defer arena.deinit();
10+
11+
const allocator = arena.allocator();
12+
13+
const ruuntimeFile = "runtime_spec.json";
14+
const ruuntimeFile_path = try std.mem.concat(
15+
allocator,
16+
u8,
17+
&.{ "./tests/fixtures/", ruuntimeFile },
18+
);
19+
const spec = try runtime.Spec.initFromFile(allocator, ruuntimeFile_path);
20+
21+
try testing.expectEqualStrings(spec.ociVersion, "0.5.0-dev");
22+
}

0 commit comments

Comments
 (0)