Borg/pkg/tim/tim_more_test.go
google-labs-jules[bot] 3398fabb14 feat: Add trix encryption and format
This commit introduces the `Enchantrix` library to add support for the `.trix` encrypted file format.

The main changes are:

- The `matrix` format has been renamed to `tim` (Terminal Isolation Matrix).
- The `.tim` format is now a specialized `.trix` file.
- A new `decode` command has been added to decode `.trix` and `.tim` files.
- The `collect` commands now support the `trix` and `tim` formats.
- A `--password` flag has been added to the `collect` commands for encryption.
- A `--i-am-in-isolation` flag has been added to the `decode` command for safely decoding `.tim` files.
- The decryption functionality is currently disabled due to a bug in the `Enchantrix` library. A follow-up PR will be created to re-enable it.
2025-11-14 13:47:27 +00:00

54 lines
1 KiB
Go

package tim
import (
"os"
"testing"
"github.com/Snider/Borg/pkg/datanode"
)
func TestMain(m *testing.M) {
os.Exit(m.Run())
}
func TestFromDataNode_Good(t *testing.T) {
dn := setupDataNode(t)
m, err := FromDataNode(dn)
if err != nil {
t.Fatalf("FromDataNode() error = %v", err)
}
if m == nil {
t.Fatal("FromDataNode() returned a nil tim")
}
if m.RootFS != dn {
t.Error("FromDataNode() did not set the RootFS correctly")
}
}
func TestToTar_Good(t *testing.T) {
m := setupTestTim(t)
_, err := m.ToTar()
if err != nil {
t.Fatalf("ToTar() error = %v", err)
}
}
// setupDataNode creates a simple DataNode for testing.
func setupDataNode(t *testing.T) *datanode.DataNode {
t.Helper()
dn := datanode.New()
dn.AddData("test.txt", []byte("hello"))
return dn
}
// setupTestTim creates a simple TerminalIsolationMatrix for testing.
func setupTestTim(t *testing.T) *TerminalIsolationMatrix {
t.Helper()
m, err := New()
if err != nil {
t.Fatalf("New() failed: %v", err)
}
m.RootFS = setupDataNode(t)
return m
}