@@ -11,6 +11,7 @@ import (
11
11
"path/filepath"
12
12
"runtime"
13
13
"testing"
14
+ "time"
14
15
15
16
"github.com/stretchr/testify/assert"
16
17
"github.com/stretchr/testify/mock"
@@ -328,6 +329,24 @@ func TestRollback(t *testing.T) {
328
329
}
329
330
}
330
331
332
+ func TestInvokeCmd (t * testing.T ) {
333
+ agentExecutable := "elastic-agent"
334
+ rollbackWindow := 2 * time .Hour + 15 * time .Minute
335
+ cmd := invokeCmd (agentExecutable , rollbackWindow )
336
+
337
+ // Expected command:
338
+ // elastic-agent watch --path.config /some/path --path.home /some/path --rollback.window 8100s
339
+ require .Len (t , cmd .Args , 8 )
340
+ require .Equal (t , agentExecutable , cmd .Args [0 ])
341
+ require .Equal (t , "watch" , cmd .Args [1 ])
342
+ require .Equal (t , "--path.config" , cmd .Args [2 ])
343
+ require .NotEmpty (t , cmd .Args [3 ])
344
+ require .Equal (t , "--path.home" , cmd .Args [4 ])
345
+ require .NotEmpty (t , cmd .Args [5 ])
346
+ require .Equal (t , "--rollback.window" , cmd .Args [6 ])
347
+ require .Equal (t , "8100s" , cmd .Args [7 ])
348
+ }
349
+
331
350
// checkFilesAfterCleanup is a convenience function to check the file structure within topDir.
332
351
// *AgentHome paths must be the expected old and new agent paths relative to topDir (typically in the form of "data/elastic-agent-*")
333
352
func checkFilesAfterCleanup (t * testing.T , topDir , newAgentHome string , oldAgentHomes ... string ) {
0 commit comments