adds option structs, ready for Show implementation

This commit is contained in:
Tai Groot
2021-05-15 13:49:34 -07:00
parent 7bedb452e4
commit 8a7c865b5f
5 changed files with 145 additions and 78 deletions

View File

@@ -10,7 +10,10 @@ func TestEnableNonexistant(t *testing.T) {
unit := "nonexistant"
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
defer cancel()
err := Enable(ctx, unit, true)
opts := Options{
usermode: true,
}
err := Enable(ctx, unit, opts)
if err != ErrDoesNotExist {
t.Errorf("error is %v, but should have been %v", err, ErrDoesNotExist)
}
@@ -23,7 +26,10 @@ func TestEnableNoPermissions(t *testing.T) {
unit := "nginx"
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
defer cancel()
err := Enable(ctx, unit, false)
opts := Options{
usermode: false,
}
err := Enable(ctx, unit, opts)
if err != ErrInsufficientPermissions {
t.Errorf("error is %v, but should have been %v", err, ErrInsufficientPermissions)
}
@@ -37,7 +43,10 @@ func TestEnableSuccess(t *testing.T) {
unit := "syncthing"
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
defer cancel()
err := Enable(ctx, unit, true)
opts := Options{
usermode: true,
}
err := Enable(ctx, unit, opts)
if err != nil {
t.Errorf("error is %v, but should have been %v", err, nil)
}