@@ -33,25 +33,38 @@ var _ = Describe("podman machine ssh", func() {
3333
3434 It ("ssh to running machine and check os-type" , func () {
3535 wsl := testProvider .VMType () == define .WSLVirt
36- name := randomString ()
36+
37+ // setting this name instead of randomized because we want to test when the
38+ // machine name is and is not provided. That's what the loop below is for
39+
40+ name := "podman-machine-default"
3741 i := new (initMachine )
38- session , err := mb .setName (name ).setCmd (i .withImage (mb .imagePath ).withNow ()).run ()
42+ session , err := mb .setName (name ).setCmd (i .withImage (mb .imagePath ).withNow (). withUpdateConnection ( ptrBool ( true )) ).run ()
3943 Expect (err ).ToNot (HaveOccurred ())
4044 Expect (session ).To (Exit (0 ))
4145
46+ // pass 1
4247 ssh := & sshMachine {}
43- sshSession , err := mb .setName (name ).setCmd (ssh .withSSHCommand ([]string {"cat" , "/etc/os-release" })).run ()
44- Expect (err ).ToNot (HaveOccurred ())
45- Expect (sshSession ).To (Exit (0 ))
48+ // pass 2
49+ bm := basicMachine {}
50+ var mcs []machineCommand
51+ // check with the machine name
52+ mcs = append (mcs , ssh .withSSHCommand ([]string {"cat" , "/etc/os-release" }))
53+ // check without the machine name
54+ mcs = append (mcs , bm .withPodmanCommand ([]string {"machine" , "ssh" , "cat" , "/etc/os-release" }))
55+ for _ , mc := range mcs {
56+ sshSession , err := mb .setCmd (mc ).run ()
57+ Expect (err ).ToNot (HaveOccurred ())
58+ Expect (sshSession ).To (Exit (0 ))
4659
47- if wsl {
48- Expect (sshSession .outputToString ()).To (ContainSubstring ("Fedora Linux" ))
49- } else {
50- Expect (sshSession .outputToString ()).To (ContainSubstring ("Fedora CoreOS" ))
60+ if wsl {
61+ Expect (sshSession .outputToString ()).To (ContainSubstring ("Fedora Linux" ))
62+ } else {
63+ Expect (sshSession .outputToString ()).To (ContainSubstring ("Fedora CoreOS" ))
64+ }
5165 }
52-
5366 // keep exit code
54- sshSession , err = mb .setName (name ).setCmd (ssh .withSSHCommand ([]string {"false" })).run ()
67+ sshSession , err : = mb .setName (name ).setCmd (ssh .withSSHCommand ([]string {"false" })).run ()
5568 Expect (err ).ToNot (HaveOccurred ())
5669 Expect (sshSession ).To (Exit (1 ))
5770 Expect (sshSession .outputToString ()).To (Equal ("" ))
0 commit comments