test: add error checks in copyFromPod
Add error checks to fix an error raised
by nogo during build time analysis.
@@ -409,8 +409,14 @@ func copyFromPod(virtCli kubecli.KubevirtClient, pod *k8sv1.Pod, containerName,
stderrBuf bytes.Buffer
)
file, err := os.Create(targetFile)
+ if err != nil {
+ Expect(err).ToNot(HaveOccurred())
+ }
+ defer func() {
+ if err := file.Close(); err != nil {
Expect(err).ToNot(HaveOccurred())
- defer file.Close()
+ }
+ }()
options := remotecommand.StreamOptions{
Stdout: file,
