From de1ab2d0d1d0a9ea0bd09e0f0db10f71b49ac746 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Motiejus=20Jak=C5=A1tys?= Date: Tue, 12 Jul 2022 14:05:43 +0300 Subject: [PATCH] turbo-getgroup: the primary users should not be returned --- src/Corpus.zig | 2 +- src/turbo-getent.zig | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) 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); + } +}