add success case to tests
This commit is contained in:
parent
feff1f6edd
commit
7bedb452e4
@ -36,7 +36,6 @@ func Stop(ctx context.Context, unit string, usermode bool) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO
|
|
||||||
func Enable(ctx context.Context, unit string, usermode bool) error {
|
func Enable(ctx context.Context, unit string, usermode bool) error {
|
||||||
var args = []string{"enable", "--system", unit}
|
var args = []string{"enable", "--system", unit}
|
||||||
if usermode {
|
if usermode {
|
||||||
@ -56,7 +55,6 @@ func Enable(ctx context.Context, unit string, usermode bool) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO
|
|
||||||
func Disable(ctx context.Context, unit string, usermode bool) error {
|
func Disable(ctx context.Context, unit string, usermode bool) error {
|
||||||
var args = []string{"disable", "--system", unit}
|
var args = []string{"disable", "--system", unit}
|
||||||
if usermode {
|
if usermode {
|
||||||
|
@ -16,6 +16,9 @@ func TestEnableNonexistant(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Note: test assumes your user isn't root and doesn't have a PolKit rule allowing access
|
||||||
|
// to configure nginx. Whether it's installed should be irrelevant.
|
||||||
func TestEnableNoPermissions(t *testing.T) {
|
func TestEnableNoPermissions(t *testing.T) {
|
||||||
unit := "nginx"
|
unit := "nginx"
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
|
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
|
||||||
@ -26,3 +29,16 @@ func TestEnableNoPermissions(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Note: requires the syncthing unit to be available on the tester's system.
|
||||||
|
// this is just what was available on mine, should you want to change it,
|
||||||
|
// either to something in this repo or more common, feel free to submit a PR.
|
||||||
|
func TestEnableSuccess(t *testing.T) {
|
||||||
|
unit := "syncthing"
|
||||||
|
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
|
||||||
|
defer cancel()
|
||||||
|
err := Enable(ctx, unit, true)
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("error is %v, but should have been %v", err, nil)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user