@@ -34,7 +34,7 @@ func jobByLabel(jobs []launchd.Job, label string) (launchd.Job, bool) {
3434
3535func TestVaultJobsWebIsBuiltIn (t * testing.T ) {
3636 home := t .TempDir ()
37- jobs := VaultJobs ("/vaults/work" , "work" , "/usr/local/bin/hebb" , t .TempDir (), home , 4399 , []string {"web" }, false )
37+ jobs := VaultJobs ("/vaults/work" , "work" , "/usr/local/bin/hebb" , t .TempDir (), home , 4399 , []string {"web" }, false , nil )
3838 j , ok := jobByLabel (jobs , "local.hebb.work.web" )
3939 if ! ok {
4040 t .Fatalf ("web job not built; got %d jobs" , len (jobs ))
@@ -59,7 +59,7 @@ func TestVaultJobsAutomationGatedOnScript(t *testing.T) {
5959
6060 // Without the scripts present, automation jobs are skipped.
6161 jobs := VaultJobs ("/vaults/work" , "work" , "hebb" , assetRoot , home , 4321 ,
62- []string {"daily-digest" , "action-review" }, false )
62+ []string {"daily-digest" , "action-review" }, false , nil )
6363 if len (jobs ) != 0 {
6464 t .Errorf ("expected automation jobs skipped when scripts absent, got %d" , len (jobs ))
6565 }
@@ -75,7 +75,7 @@ func TestVaultJobsAutomationGatedOnScript(t *testing.T) {
7575 }
7676 }
7777 jobs = VaultJobs ("/vaults/work" , "work" , "hebb" , assetRoot , home , 4321 ,
78- []string {"daily-digest" , "action-review" }, false )
78+ []string {"daily-digest" , "action-review" }, false , nil )
7979
8080 digest , ok := jobByLabel (jobs , "local.hebb.work.daily-digest" )
8181 if ! ok {
@@ -110,16 +110,55 @@ func TestVaultJobsAutomationGatedOnScript(t *testing.T) {
110110 }
111111}
112112
113+ func TestVaultJobsAppendsPerJobArgs (t * testing.T ) {
114+ home := t .TempDir ()
115+ assetRoot := t .TempDir ()
116+ autoDir := filepath .Join (assetRoot , "automation" )
117+ if err := os .MkdirAll (autoDir , 0o755 ); err != nil {
118+ t .Fatal (err )
119+ }
120+ if err := os .WriteFile (filepath .Join (autoDir , "generate-action-review.py" ), []byte ("#!/usr/bin/env python3\n " ), 0o755 ); err != nil {
121+ t .Fatal (err )
122+ }
123+
124+ jobArgs := map [string ][]string {
125+ "action-review" : {"--owner" , "Alex Doe" , "--mine-output" , "2-Areas/_MY-OPEN-ACTIONS.md" },
126+ "bogus" : {"--ignored" },
127+ }
128+ jobs := VaultJobs ("/vaults/work" , "work" , "hebb" , assetRoot , home , 4321 ,
129+ []string {"action-review" , "web" }, false , jobArgs )
130+
131+ review , ok := jobByLabel (jobs , "local.hebb.work.action-review" )
132+ if ! ok {
133+ t .Fatal ("action-review job not built" )
134+ }
135+ prog := strings .Join (review .Program , " " )
136+ for _ , want := range []string {"--vault-root /vaults/work" , "--owner Alex Doe" , "--mine-output 2-Areas/_MY-OPEN-ACTIONS.md" } {
137+ if ! strings .Contains (prog , want ) {
138+ t .Errorf ("action-review program %q missing %q" , prog , want )
139+ }
140+ }
141+
142+ // Jobs without configured args are untouched.
143+ web , ok := jobByLabel (jobs , "local.hebb.work.web" )
144+ if ! ok {
145+ t .Fatal ("web job not built" )
146+ }
147+ if got := strings .Join (web .Program , " " ); strings .Contains (got , "--owner" ) || strings .Contains (got , "--ignored" ) {
148+ t .Errorf ("web program %q should not pick up other jobs' args" , got )
149+ }
150+ }
151+
113152func TestVaultJobsSkipsUnknown (t * testing.T ) {
114- jobs := VaultJobs ("/v" , "v" , "hebb" , t .TempDir (), t .TempDir (), 4321 , []string {"web" , "bogus" }, false )
153+ jobs := VaultJobs ("/v" , "v" , "hebb" , t .TempDir (), t .TempDir (), 4321 , []string {"web" , "bogus" }, false , nil )
115154 if len (jobs ) != 1 {
116155 t .Errorf ("unknown job name should be skipped, got %d jobs" , len (jobs ))
117156 }
118157}
119158
120159func TestVaultJobsUpdateCheck (t * testing.T ) {
121160 // Default: the scheduled job only checks (notifies).
122- jobs := VaultJobs ("/v" , "v" , "hebb" , t .TempDir (), t .TempDir (), 4321 , []string {"update-check" }, false )
161+ jobs := VaultJobs ("/v" , "v" , "hebb" , t .TempDir (), t .TempDir (), 4321 , []string {"update-check" }, false , nil )
123162 j , ok := jobByLabel (jobs , "local.hebb.v.update-check" )
124163 if ! ok {
125164 t .Fatal ("update-check job not built" )
@@ -132,7 +171,7 @@ func TestVaultJobsUpdateCheck(t *testing.T) {
132171 }
133172
134173 // auto = true: the job applies the update instead.
135- jobs = VaultJobs ("/v" , "v" , "hebb" , t .TempDir (), t .TempDir (), 4321 , []string {"update-check" }, true )
174+ jobs = VaultJobs ("/v" , "v" , "hebb" , t .TempDir (), t .TempDir (), 4321 , []string {"update-check" }, true , nil )
136175 j , _ = jobByLabel (jobs , "local.hebb.v.update-check" )
137176 if got := strings .Join (j .Program , " " ); ! strings .Contains (got , "update" ) || strings .Contains (got , "--check" ) {
138177 t .Errorf ("auto update-check should run 'update' without --check, got %q" , got )
0 commit comments