mirror of
				https://github.com/containers/podman.git
				synced 2025-11-04 08:56:05 +08:00 
			
		
		
		
	Stop using rm'd inspect format templates in tests
Fixes the "machine rm --save-ignition --save-image" test so that it no longer
uses the `{{ .Image }}` format string.
Fixes the "init should cleanup on failure" test so that it no longer
uses the `{{ .Image }}` and `{{ .ConfigPath }}` format strings.
Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
			
			
This commit is contained in:
		@ -287,16 +287,6 @@ var _ = Describe("podman machine init", func() {
 | 
				
			|||||||
		Expect(err).ToNot(HaveOccurred())
 | 
							Expect(err).ToNot(HaveOccurred())
 | 
				
			||||||
		cfgpth := filepath.Join(inspectSession.outputToString(), fmt.Sprintf("%s.json", name))
 | 
							cfgpth := filepath.Join(inspectSession.outputToString(), fmt.Sprintf("%s.json", name))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		inspect = inspect.withFormat("{{.Image.IgnitionFile.Path}}")
 | 
					 | 
				
			||||||
		inspectSession, err = mb.setCmd(inspect).run()
 | 
					 | 
				
			||||||
		Expect(err).ToNot(HaveOccurred())
 | 
					 | 
				
			||||||
		ign := inspectSession.outputToString()
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		inspect = inspect.withFormat("{{.Image.ImagePath.Path}}")
 | 
					 | 
				
			||||||
		inspectSession, err = mb.setCmd(inspect).run()
 | 
					 | 
				
			||||||
		Expect(err).ToNot(HaveOccurred())
 | 
					 | 
				
			||||||
		img := inspectSession.outputToString()
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		rm := rmMachine{}
 | 
							rm := rmMachine{}
 | 
				
			||||||
		removeSession, err := mb.setCmd(rm.withForce()).run()
 | 
							removeSession, err := mb.setCmd(rm.withForce()).run()
 | 
				
			||||||
		Expect(err).ToNot(HaveOccurred())
 | 
							Expect(err).ToNot(HaveOccurred())
 | 
				
			||||||
@ -317,13 +307,17 @@ var _ = Describe("podman machine init", func() {
 | 
				
			|||||||
			Expect(err).ToNot(HaveOccurred())
 | 
								Expect(err).ToNot(HaveOccurred())
 | 
				
			||||||
			Expect(session).To(Exit(125))
 | 
								Expect(session).To(Exit(125))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			// ensure files created by init are cleaned up on init failure
 | 
								imageSuffix := mb.imagePath[strings.LastIndex(mb.imagePath, "/")+1:]
 | 
				
			||||||
			_, err = os.Stat(img)
 | 
								imgPath := filepath.Join(testDir, ".local", "share", "containers", "podman", "machine", "qemu", mb.name+"_"+imageSuffix)
 | 
				
			||||||
 | 
								_, err = os.Stat(imgPath)
 | 
				
			||||||
			Expect(err).To(HaveOccurred())
 | 
								Expect(err).To(HaveOccurred())
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								cfgDir := filepath.Join(testDir, ".config", "containers", "podman", "machine", testProvider.VMType().String())
 | 
				
			||||||
			_, err = os.Stat(cfgpth)
 | 
								_, err = os.Stat(cfgpth)
 | 
				
			||||||
			Expect(err).To(HaveOccurred())
 | 
								Expect(err).To(HaveOccurred())
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			_, err = os.Stat(ign)
 | 
								ignPath := filepath.Join(cfgDir, mb.name+".ign")
 | 
				
			||||||
 | 
								_, err = os.Stat(ignPath)
 | 
				
			||||||
			Expect(err).To(HaveOccurred())
 | 
								Expect(err).To(HaveOccurred())
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
				
			|||||||
@ -94,16 +94,6 @@ var _ = Describe("podman machine rm", func() {
 | 
				
			|||||||
		key := inspectSession.outputToString()
 | 
							key := inspectSession.outputToString()
 | 
				
			||||||
		pubkey := key + ".pub"
 | 
							pubkey := key + ".pub"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		inspect = inspect.withFormat("{{.Image.IgnitionFile.Path}}")
 | 
					 | 
				
			||||||
		inspectSession, err = mb.setCmd(inspect).run()
 | 
					 | 
				
			||||||
		Expect(err).ToNot(HaveOccurred())
 | 
					 | 
				
			||||||
		ign := inspectSession.outputToString()
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		inspect = inspect.withFormat("{{.Image.ImagePath.Path}}")
 | 
					 | 
				
			||||||
		inspectSession, err = mb.setCmd(inspect).run()
 | 
					 | 
				
			||||||
		Expect(err).ToNot(HaveOccurred())
 | 
					 | 
				
			||||||
		img := inspectSession.outputToString()
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		rm := rmMachine{}
 | 
							rm := rmMachine{}
 | 
				
			||||||
		removeSession, err := mb.setCmd(rm.withForce().withSaveIgnition().withSaveImage()).run()
 | 
							removeSession, err := mb.setCmd(rm.withForce().withSaveIgnition().withSaveImage()).run()
 | 
				
			||||||
		Expect(err).ToNot(HaveOccurred())
 | 
							Expect(err).ToNot(HaveOccurred())
 | 
				
			||||||
@ -122,10 +112,11 @@ var _ = Describe("podman machine rm", func() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		// WSL does not use ignition
 | 
							// WSL does not use ignition
 | 
				
			||||||
		if testProvider.VMType() != define.WSLVirt {
 | 
							if testProvider.VMType() != define.WSLVirt {
 | 
				
			||||||
			_, err = os.Stat(ign)
 | 
								ignPath := filepath.Join(testDir, ".config", "containers", "podman", "machine", testProvider.VMType().String(), mb.name+".ign")
 | 
				
			||||||
 | 
								_, err = os.Stat(ignPath)
 | 
				
			||||||
			Expect(err).ToNot(HaveOccurred())
 | 
								Expect(err).ToNot(HaveOccurred())
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		_, err = os.Stat(img)
 | 
							_, err = os.Stat(mb.imagePath)
 | 
				
			||||||
		Expect(err).ToNot(HaveOccurred())
 | 
							Expect(err).ToNot(HaveOccurred())
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user