diff --git a/src/Corpus.zig b/src/Corpus.zig index a9b8ddf..02af4fa 100644 --- a/src/Corpus.zig +++ b/src/Corpus.zig @@ -270,7 +270,7 @@ pub fn testCorpus(allocator: Allocator) !Corpus { allocator, 100000, "service-account", - &[_][]const u8{ "svc-bar", "vidmantas" }, + &[_][]const u8{ "svc-bar", "vidmantas", "root" }, ); defer group0.deinit(allocator); defer group1.deinit(allocator); diff --git a/src/turbo-getent.zig b/src/turbo-getent.zig index e604254..5319429 100644 --- a/src/turbo-getent.zig +++ b/src/turbo-getent.zig @@ -249,3 +249,33 @@ test "turbo-getent passwd_all" { i += 1; } } + +test "turbo-getent group" { + var tf = try File.TestDB.init(testing.allocator); + defer tf.deinit(); + var stdout = ArrayList(u8).init(testing.allocator); + defer stdout.deinit(); + var stderr = ArrayList(u8).init(testing.allocator); + defer stderr.deinit(); + + { + const args = &[_][*:0]const u8{ + "--db", + tf.path, + "group", + "root", + "doesnotexist", + "svc-bar", + "0", + "1", + }; + const got = execute(stdout.writer(), stderr.writer(), args); + try testing.expectEqual(got, 2); + const want = + \\root:x:0: + \\svc-bar:x:128:root,vidmantas + \\ + ; + try testing.expectEqualStrings(want, stdout.items); + } +}