Move module declaration and all internal imports from github.com/Snider/Borg to forge.lthn.ai/Snider/Borg. Also updates Enchantrix dependency path to forge.lthn.ai/Snider/Enchantrix. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
44 lines
1,014 B
Go
44 lines
1,014 B
Go
package cmd
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"forge.lthn.ai/Snider/Borg/pkg/datanode"
|
|
"forge.lthn.ai/Snider/Borg/pkg/trix"
|
|
)
|
|
|
|
func TestDecodeCmd(t *testing.T) {
|
|
t.Run("Good", func(t *testing.T) {
|
|
tempDir := t.TempDir()
|
|
outputFile := filepath.Join(tempDir, "decoded.dat")
|
|
inputFile := filepath.Join(tempDir, "test.trix")
|
|
|
|
// Create a dummy trix file.
|
|
dn := datanode.New()
|
|
dn.AddData("test.txt", []byte("hello"))
|
|
trixBytes, err := trix.ToTrix(dn, "")
|
|
if err != nil {
|
|
t.Fatalf("failed to create trix file: %v", err)
|
|
}
|
|
err = os.WriteFile(inputFile, trixBytes, 0644)
|
|
if err != nil {
|
|
t.Fatalf("failed to write trix file: %v", err)
|
|
}
|
|
|
|
// Execute the decode command.
|
|
cmd := NewDecodeCmd()
|
|
cmd.SetArgs([]string{inputFile, "--output", outputFile})
|
|
err = cmd.Execute()
|
|
if err != nil {
|
|
t.Fatalf("decode command failed: %v", err)
|
|
}
|
|
|
|
// Verify the output file.
|
|
_, err = os.Stat(outputFile)
|
|
if err != nil {
|
|
t.Fatalf("output file not found: %v", err)
|
|
}
|
|
})
|
|
}
|