feat: error/success hooks
This commit is contained in:
36
internal/jobs/jobs_test.go
Normal file
36
internal/jobs/jobs_test.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package jobs_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"git.gentoo.party/sam/thanks/internal/jobs"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func Test_JobHookError(t *testing.T) {
|
||||
job := jobs.BackupJob{
|
||||
Target: "znothing/nothing",
|
||||
TargetHost: "devnull",
|
||||
Source: "zempty/empty",
|
||||
Keep: 1,
|
||||
MaxAge: 1 * time.Second,
|
||||
Recursive: false,
|
||||
Hooks: jobs.BackupHooks{
|
||||
Error: jobs.BackupHookCommand{
|
||||
Command: "/usr/bin/notify-send",
|
||||
Args: []string{"--app-name=thanks", "--urgency=CRITICAL", "Backup Failure", "Backup failed"},
|
||||
Env: []string{
|
||||
"XDG_RUNTIME_DIR=/run/user/1000/",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
var hookErr *jobs.HookErr
|
||||
|
||||
err := job.Do(context.Background())
|
||||
assert.NotNil(t, err, "expected job to produce an error")
|
||||
assert.NotErrorAsf(t, err, &hookErr, "expected a non-hook error, got %w", err)
|
||||
}
|
||||
Reference in New Issue
Block a user