From 679e719f9e4d9230482491bf253a0d538f030f08 Mon Sep 17 00:00:00 2001 From: Ophestra Umiker Date: Thu, 17 Oct 2024 20:28:55 +0900 Subject: system: tests for all Op implementations except DBus Signed-off-by: Ophestra Umiker --- internal/system/xhost_test.go | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 internal/system/xhost_test.go (limited to 'internal/system/xhost_test.go') diff --git a/internal/system/xhost_test.go b/internal/system/xhost_test.go new file mode 100644 index 00000000..4b364432 --- /dev/null +++ b/internal/system/xhost_test.go @@ -0,0 +1,34 @@ +package system + +import ( + "testing" +) + +func TestChangeHosts(t *testing.T) { + testCases := []string{"chronos", "keyring", "cat", "kbd", "yonah"} + for _, tc := range testCases { + t.Run("append ChangeHosts operation for "+tc, func(t *testing.T) { + sys := New(150) + sys.ChangeHosts(tc) + (&tcOp{EX11, tc}).test(t, sys.ops, []Op{ + XHost(tc), + }, "ChangeHosts") + }) + } +} + +func TestXHost_String(t *testing.T) { + testCases := []struct { + username string + want string + }{ + {"chronos", "SI:localuser:chronos"}, + } + for _, tc := range testCases { + t.Run(tc.want, func(t *testing.T) { + if got := XHost(tc.username).String(); got != tc.want { + t.Errorf("String() = %v, want %v", got, tc.want) + } + }) + } +} -- cgit v1.3.1