From 125e4771ddc1374492011aee953cf93d8ffbf78b Mon Sep 17 00:00:00 2001 From: Tai Groot Date: Sun, 16 May 2021 23:19:59 -0700 Subject: [PATCH] cleans up comments, adds short testing options to more tests --- errors_test.go | 18 ------------------ helpers_test.go | 9 +++++++++ systemctl_test.go | 3 +++ 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/errors_test.go b/errors_test.go index aaa0743..5e1713d 100644 --- a/errors_test.go +++ b/errors_test.go @@ -72,21 +72,3 @@ func TestErrorFuncs(t *testing.T) { }) } } - -// /* Run these tests only as a user */ -// -// // fail to reload system daemon as user -// {"", ErrInsufficientPermissions, Options{UserMode: false}, true}, -// // reload user's scope daemon -// {"", nil, Options{UserMode: true}, true}, -// /* End user tests*/ -// -// /* Run these tests only as a superuser */ -// -// // succeed to reload daemon -// {"", nil, Options{UserMode: false}, false}, -// // fail to connect to user bus as system -// {"", ErrBusFailure, Options{UserMode: true}, false}, -// -// /* End superuser tests*/ -// diff --git a/helpers_test.go b/helpers_test.go index d4a3049..c43a04b 100644 --- a/helpers_test.go +++ b/helpers_test.go @@ -17,6 +17,9 @@ import ( // - your user doesn't have a PolKit rule allowing access to configure nginx func TestGetStartTime(t *testing.T) { + if testing.Short() { + t.Skip("skipping in short mode") + } testCases := []struct { unit string err error @@ -132,6 +135,9 @@ func TestGetNumRestarts(t *testing.T) { } // Prove restart count increases by one after a restart t.Run(fmt.Sprintf("prove restart count increases by one after a restart"), func(t *testing.T) { + if testing.Short() { + t.Skip("skipping in short mode") + } if userString != "root" && userString != "system" { t.Skip("skipping superuser test while running as user") } @@ -268,6 +274,9 @@ func TestGetPID(t *testing.T) { }) } t.Run(fmt.Sprintf("prove pid changes"), func(t *testing.T) { + if testing.Short() { + t.Skip("skipping in short mode") + } if userString != "root" && userString != "system" { t.Skip("skipping superuser test while running as user") } diff --git a/systemctl_test.go b/systemctl_test.go index 0a3eb9c..eb45b4c 100644 --- a/systemctl_test.go +++ b/systemctl_test.go @@ -147,6 +147,9 @@ func ExampleEnable() { func TestIsActive(t *testing.T) { unit := "nginx" t.Run(fmt.Sprintf("check active"), func(t *testing.T) { + if testing.Short() { + t.Skip("skipping in short mode") + } if userString != "root" && userString != "system" { t.Skip("skipping superuser test while running as user") }