mirror of
https://github.com/taigrr/systemctl.git
synced 2025-10-05 16:26:58 +08:00
check stderr before reporting back error 1
This commit is contained in:
28
systemctl_test.go
Normal file
28
systemctl_test.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package systemctl
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestEnableNonexistant(t *testing.T) {
|
||||
unit := "nonexistant"
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
|
||||
defer cancel()
|
||||
err := Enable(ctx, unit, true)
|
||||
if err != ErrDoesNotExist {
|
||||
t.Errorf("error is %v, but should have been %v", err, ErrDoesNotExist)
|
||||
}
|
||||
|
||||
}
|
||||
func TestEnableNoPermissions(t *testing.T) {
|
||||
unit := "nginx"
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
|
||||
defer cancel()
|
||||
err := Enable(ctx, unit, false)
|
||||
if err != ErrInsufficientPermissions {
|
||||
t.Errorf("error is %v, but should have been %v", err, ErrInsufficientPermissions)
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user