mirror of
https://github.com/Awuqing/BackupX.git
synced 2026-05-27 19:19:35 +08:00
- fix bare-metal Agent install config and executor path handling - support release package layout in deploy/install.sh and release workflow - add regression tests for Agent execution and deploy install script behavior
35 lines
884 B
Go
35 lines
884 B
Go
package agent
|
|
|
|
import (
|
|
"reflect"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestBuildBackupTaskSpecParsesJSONSourcePaths(t *testing.T) {
|
|
spec := &TaskSpec{
|
|
TaskID: 7,
|
|
Name: "root-files",
|
|
Type: "file",
|
|
SourcePaths: `["/root","/etc"]`,
|
|
ExcludePatterns: `["*.log","tmp"]`,
|
|
}
|
|
|
|
got := buildBackupTaskSpec(spec, time.Unix(0, 0), "/var/lib/backupx-agent/tmp")
|
|
|
|
if !reflect.DeepEqual(got.SourcePaths, []string{"/root", "/etc"}) {
|
|
t.Fatalf("source paths = %#v", got.SourcePaths)
|
|
}
|
|
if !reflect.DeepEqual(got.ExcludePatterns, []string{"*.log", "tmp"}) {
|
|
t.Fatalf("exclude patterns = %#v", got.ExcludePatterns)
|
|
}
|
|
}
|
|
|
|
func TestParseStringListFieldKeepsLegacyLineFormat(t *testing.T) {
|
|
got := parseStringListField("/root\n /etc \n")
|
|
want := []string{"/root", "/etc"}
|
|
if !reflect.DeepEqual(got, want) {
|
|
t.Fatalf("paths = %#v, want %#v", got, want)
|
|
}
|
|
}
|