@@ -39,6 +39,7 @@ func newMockeyCLIContext(t *testing.T, args []string) *cli.Context {
3939 _ = flags .String ("data-dir" , "" , "" )
4040 _ = flags .String ("token" , "" , "" )
4141 _ = flags .String ("endpoint" , "" , "" )
42+ _ = flags .String ("session-protocol" , config .DefaultSessionProtocol , "" )
4243 _ = flags .String ("machine-id" , "" , "" )
4344 _ = flags .Bool ("machine-id-overwrite" , false , "" )
4445 _ = flags .Bool ("refresh-session-token" , false , "" )
@@ -113,7 +114,7 @@ func TestCommand_LoginSuccessWithRecordStateError(t *testing.T) {
113114 }).Build ()
114115 mockey .Mock (pkdsystemd .SystemctlExists ).To (func () bool { return true }).Build ()
115116 mockey .Mock (systemd .DefaultBinExists ).To (func () bool { return true }).Build ()
116- mockey .Mock (systemd .CreateDefaultEnvFile ).To (func (endpoint , dataDir string , dbInMemory bool ) error {
117+ mockey .Mock (systemd .CreateDefaultEnvFile ).To (func (endpoint , dataDir string , dbInMemory bool , sessionProtocol ... string ) error {
117118 return nil
118119 }).Build ()
119120 mockey .Mock (systemd .GPUdServiceUnitFileContents ).To (func () string {
@@ -165,7 +166,7 @@ func TestCommand_WithAllFlags(t *testing.T) {
165166 }).Build ()
166167 mockey .Mock (pkdsystemd .SystemctlExists ).To (func () bool { return true }).Build ()
167168 mockey .Mock (systemd .DefaultBinExists ).To (func () bool { return true }).Build ()
168- mockey .Mock (systemd .CreateDefaultEnvFile ).To (func (endpoint , dataDir string , dbInMemory bool ) error {
169+ mockey .Mock (systemd .CreateDefaultEnvFile ).To (func (endpoint , dataDir string , dbInMemory bool , sessionProtocol ... string ) error {
169170 return nil
170171 }).Build ()
171172 mockey .Mock (systemd .GPUdServiceUnitFileContents ).To (func () string {
@@ -275,7 +276,7 @@ func TestCommand_WithEmptyToken(t *testing.T) {
275276 }).Build ()
276277 mockey .Mock (pkdsystemd .SystemctlExists ).To (func () bool { return true }).Build ()
277278 mockey .Mock (systemd .DefaultBinExists ).To (func () bool { return true }).Build ()
278- mockey .Mock (systemd .CreateDefaultEnvFile ).To (func (endpoint , dataDir string , dbInMemory bool ) error {
279+ mockey .Mock (systemd .CreateDefaultEnvFile ).To (func (endpoint , dataDir string , dbInMemory bool , sessionProtocol ... string ) error {
279280 return nil
280281 }).Build ()
281282 mockey .Mock (systemd .GPUdServiceUnitFileContents ).To (func () string {
@@ -299,7 +300,7 @@ func TestCommand_WithEmptyToken(t *testing.T) {
299300func TestSystemdInit_WriteFileErrorWithDifferentPaths (t * testing.T ) {
300301 mockey .PatchConvey ("systemdInit write file error with path check" , t , func () {
301302 writtenPath := ""
302- mockey .Mock (systemd .CreateDefaultEnvFile ).To (func (endpoint , dataDir string , dbInMemory bool ) error {
303+ mockey .Mock (systemd .CreateDefaultEnvFile ).To (func (endpoint , dataDir string , dbInMemory bool , sessionProtocol ... string ) error {
303304 return nil
304305 }).Build ()
305306 mockey .Mock (systemd .GPUdServiceUnitFileContents ).To (func () string {
@@ -321,7 +322,7 @@ func TestSystemdInit_WriteFileErrorWithDifferentPaths(t *testing.T) {
321322func TestSystemdInit_WithDbInMemory (t * testing.T ) {
322323 mockey .PatchConvey ("systemdInit with db in memory" , t , func () {
323324 capturedDbInMemory := false
324- mockey .Mock (systemd .CreateDefaultEnvFile ).To (func (endpoint , dataDir string , dbInMemory bool ) error {
325+ mockey .Mock (systemd .CreateDefaultEnvFile ).To (func (endpoint , dataDir string , dbInMemory bool , sessionProtocol ... string ) error {
325326 capturedDbInMemory = dbInMemory
326327 return nil
327328 }).Build ()
@@ -471,6 +472,7 @@ func TestCommand_SystemdEnvFileWithEndpoint(t *testing.T) {
471472 tmpDir := t .TempDir ()
472473 var capturedEndpoint string
473474 var capturedDataDir string
475+ var capturedSessionProtocol string
474476
475477 mockey .Mock (common .ResolveDataDir ).To (func (cliContext * cli.Context ) (string , error ) {
476478 return tmpDir , nil
@@ -481,9 +483,10 @@ func TestCommand_SystemdEnvFileWithEndpoint(t *testing.T) {
481483 }).Build ()
482484 mockey .Mock (pkdsystemd .SystemctlExists ).To (func () bool { return true }).Build ()
483485 mockey .Mock (systemd .DefaultBinExists ).To (func () bool { return true }).Build ()
484- mockey .Mock (systemd .CreateDefaultEnvFile ).To (func (endpoint , dataDir string , dbInMemory bool ) error {
486+ mockey .Mock (systemd .CreateDefaultEnvFile ).To (func (endpoint , dataDir string , dbInMemory bool , sessionProtocol ... string ) error {
485487 capturedEndpoint = endpoint
486488 capturedDataDir = dataDir
489+ capturedSessionProtocol = sessionProtocol [0 ]
487490 return nil
488491 }).Build ()
489492 mockey .Mock (systemd .GPUdServiceUnitFileContents ).To (func () string {
@@ -495,11 +498,12 @@ func TestCommand_SystemdEnvFileWithEndpoint(t *testing.T) {
495498 mockey .Mock (pkgupdate .EnableGPUdSystemdUnit ).To (func () error { return nil }).Build ()
496499 mockey .Mock (pkgupdate .RestartGPUdSystemdUnit ).To (func () error { return nil }).Build ()
497500
498- cliContext := newMockeyCLIContext (t , []string {"--endpoint" , "https://custom.endpoint.com" })
501+ cliContext := newMockeyCLIContext (t , []string {"--endpoint" , "https://custom.endpoint.com" , "--session-protocol" , "v2" })
499502 err := Command (cliContext )
500503 require .NoError (t , err )
501504 assert .Equal (t , "https://custom.endpoint.com" , capturedEndpoint )
502505 assert .Equal (t , tmpDir , capturedDataDir )
506+ assert .Equal (t , "v2" , capturedSessionProtocol )
503507 })
504508}
505509
0 commit comments