mirror of
https://github.com/taigrr/systemctl.git
synced 2026-03-09 00:14:38 -07:00
gofumpt against remaining go files
This commit is contained in:
@@ -36,5 +36,5 @@ var (
|
||||
|
||||
// Something in the stderr output contains the word `Failed`, but it is not a known case
|
||||
// This is a catch-all, and if it's ever seen in the wild, please submit a PR
|
||||
ErrUnspecified = errors.New("Unknown error, please submit an issue at github.com/taigrr/systemctl")
|
||||
ErrUnspecified = errors.New("unknown error, please submit an issue at github.com/taigrr/systemctl")
|
||||
)
|
||||
|
||||
@@ -25,7 +25,7 @@ func TestErrorFuncs(t *testing.T) {
|
||||
}{
|
||||
/* Run these tests only as an unpriviledged user */
|
||||
|
||||
//try nonexistant unit in user mode as user
|
||||
// try nonexistant unit in user mode as user
|
||||
{"nonexistant", ErrDoesNotExist, Options{UserMode: true}, true},
|
||||
// try existing unit in user mode as user
|
||||
{"syncthing", nil, Options{UserMode: true}, true},
|
||||
@@ -53,7 +53,6 @@ func TestErrorFuncs(t *testing.T) {
|
||||
fName := runtime.FuncForPC(reflect.ValueOf(f).Pointer()).Name()
|
||||
fName = strings.TrimPrefix(fName, "github.com/taigrr/")
|
||||
t.Run(fmt.Sprintf("Errorcheck %s", fName), func(t *testing.T) {
|
||||
|
||||
for _, tc := range errCases {
|
||||
t.Run(fmt.Sprintf("%s as %s", tc.unit, userString), func(t *testing.T) {
|
||||
if (userString == "root" || userString == "system") && tc.runAsUser {
|
||||
|
||||
@@ -13,7 +13,6 @@ const dateFormat = "Mon 2006-01-02 15:04:05 MST"
|
||||
// Get start time of a service (`systemctl show [unit] --property ExecMainStartTimestamp`) as a `Time` type
|
||||
func GetStartTime(ctx context.Context, unit string, opts Options) (time.Time, error) {
|
||||
value, err := Show(ctx, unit, properties.ExecMainStartTimestamp, opts)
|
||||
|
||||
if err != nil {
|
||||
return time.Time{}, err
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ func TestGetStartTime(t *testing.T) {
|
||||
runAsUser bool
|
||||
}{
|
||||
// Run these tests only as a user
|
||||
//try nonexistant unit in user mode as user
|
||||
// try nonexistant unit in user mode as user
|
||||
{"nonexistant", ErrUnitNotActive, Options{UserMode: false}, true},
|
||||
// try existing unit in user mode as user
|
||||
{"syncthing", ErrUnitNotActive, Options{UserMode: true}, true},
|
||||
@@ -90,8 +90,8 @@ func TestGetStartTime(t *testing.T) {
|
||||
t.Errorf("Expected start diff to be positive, but got: %d", int(diff))
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
func TestGetNumRestarts(t *testing.T) {
|
||||
testCases := []struct {
|
||||
unit string
|
||||
@@ -101,7 +101,7 @@ func TestGetNumRestarts(t *testing.T) {
|
||||
}{
|
||||
// Run these tests only as a user
|
||||
|
||||
//try nonexistant unit in user mode as user
|
||||
// try nonexistant unit in user mode as user
|
||||
{"nonexistant", ErrValueNotSet, Options{UserMode: false}, true},
|
||||
// try existing unit in user mode as user
|
||||
{"syncthing", ErrValueNotSet, Options{UserMode: true}, true},
|
||||
@@ -170,7 +170,6 @@ func TestGetNumRestarts(t *testing.T) {
|
||||
t.Errorf("Expected restart count to differ by one, but difference was: %d", secondRestarts-restarts)
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
func TestGetMemoryUsage(t *testing.T) {
|
||||
@@ -182,7 +181,7 @@ func TestGetMemoryUsage(t *testing.T) {
|
||||
}{
|
||||
// Run these tests only as a user
|
||||
|
||||
//try nonexistant unit in user mode as user
|
||||
// try nonexistant unit in user mode as user
|
||||
{"nonexistant", ErrValueNotSet, Options{UserMode: false}, true},
|
||||
// try existing unit in user mode as user
|
||||
{"syncthing", ErrValueNotSet, Options{UserMode: true}, true},
|
||||
@@ -230,8 +229,8 @@ func TestGetMemoryUsage(t *testing.T) {
|
||||
t.Errorf("Expected memory usage between nginx and user.slice to differ, but both were: %d", bytes)
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
func TestGetPID(t *testing.T) {
|
||||
testCases := []struct {
|
||||
unit string
|
||||
@@ -241,7 +240,7 @@ func TestGetPID(t *testing.T) {
|
||||
}{
|
||||
// Run these tests only as a user
|
||||
|
||||
//try nonexistant unit in user mode as user
|
||||
// try nonexistant unit in user mode as user
|
||||
{"nonexistant", nil, Options{UserMode: false}, true},
|
||||
// try existing unit in user mode as user
|
||||
{"syncthing", nil, Options{UserMode: true}, true},
|
||||
@@ -296,7 +295,5 @@ func TestGetPID(t *testing.T) {
|
||||
if pid == secondPid {
|
||||
t.Errorf("Expected pid != secondPid, but both were: %d", pid)
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user