fix: Address various issues in compile, run, and matrix tests

This commit addresses three separate issues:

1.  **cmd/compile.go**: The `Borgfile` parsing now returns an error for
    unknown instructions instead of silently ignoring them.
2.  **cmd/run_test.go**: The `execCommand` mock is now properly cleaned
    up after the test, preventing it from leaking into other tests.
3.  **pkg/matrix/matrix_test.go**: The EOF check in the tar reader loop
    now uses a direct error comparison (`io.EOF`) instead of a string
    comparison.
This commit is contained in:
google-labs-jules[bot] 2025-11-13 19:56:13 +00:00
parent 7a76d55411
commit 2fa52bc8b4
3 changed files with 8 additions and 1 deletions

View file

@ -44,6 +44,8 @@ var compileCmd = &cobra.Command{
return err
}
m.RootFS.AddData(dest, data)
default:
return fmt.Errorf("unknown instruction: %s", parts[0])
}
}

View file

@ -65,7 +65,11 @@ func TestRunCmd_Good(t *testing.T) {
}
// Mock the exec.Command function.
origExecCommand := execCommand
execCommand = helperProcess
t.Cleanup(func() {
execCommand = origExecCommand
})
// Run the run command.
rootCmd := NewRootCmd()

View file

@ -3,6 +3,7 @@ package matrix
import (
"archive/tar"
"bytes"
"io"
"testing"
"github.com/Snider/Borg/pkg/datanode"
@ -60,7 +61,7 @@ func TestToTar(t *testing.T) {
for {
header, err := tr.Next()
if err != nil {
if err.Error() == "EOF" {
if err == io.EOF {
break
}
t.Fatalf("failed to read tar header: %v", err)