Files
wehub-resource-sync f99010fae1
CI / lint (push) Failing after 1s
CI / frontend (push) Failing after 1s
CI / scripts (push) Failing after 1s
CI / Go Test (ubuntu-latest) (push) Failing after 0s
CI / frontend-node-25 (push) Failing after 1s
CI / docs (push) Failing after 0s
CI / coverage (push) Failing after 0s
CI / e2e (push) Failing after 0s
Docker / build-and-push (push) Failing after 1s
CI / integration (push) Failing after 4m43s
CI / Go Test (windows-latest) (push) Has been cancelled
CI / Desktop Unit Tests (Windows) (push) Has been cancelled
Desktop Artifacts / Desktop Build (Linux (arm64)) (push) Has been cancelled
Desktop Artifacts / Desktop Build (Linux) (push) Has been cancelled
Desktop Artifacts / Desktop Build (Windows) (push) Has been cancelled
Desktop Artifacts (macOS) / Desktop Build (macOS (aarch64)) (push) Has been cancelled
Desktop Artifacts (macOS) / Desktop Build (macOS (x86_64)) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:30:36 +08:00

64 lines
1.9 KiB
Go

package remotesync
import (
"os"
"path/filepath"
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.kenn.io/agentsview/internal/parser"
)
func TestBuildManifestListsRegularFilesWithSizeAndMtime(t *testing.T) {
dir := t.TempDir()
sub := filepath.Join(dir, "proj")
require.NoError(t, os.MkdirAll(sub, 0o755))
a := filepath.Join(sub, "a.jsonl")
require.NoError(t, os.WriteFile(a, []byte("aaaa"), 0o644))
mtime := time.Date(2026, 7, 8, 9, 0, 0, 987654321, time.UTC)
require.NoError(t, os.Chtimes(a, mtime, mtime))
require.NoError(t, os.Symlink(a, filepath.Join(sub, "link.jsonl")))
extra := filepath.Join(dir, "index.jsonl")
require.NoError(t, os.WriteFile(extra, []byte("x"), 0o644))
m, err := BuildManifest(TargetSet{
Dirs: map[parser.AgentType][]string{parser.AgentClaude: {sub}},
ExtraFiles: []string{extra},
})
require.NoError(t, err)
// Sorted by path: <tmp>/index.jsonl precedes <tmp>/proj/a.jsonl.
require.Len(t, m.Files, 2)
assert.Equal(t, extra, m.Files[0].Path)
assert.Equal(t, a, m.Files[1].Path)
assert.Equal(t, int64(4), m.Files[1].Size)
info, err := os.Stat(a)
require.NoError(t, err)
assert.Equal(t, info.ModTime().UnixNano(), m.Files[1].MtimeNS)
}
func TestBuildManifestToleratesMissingRootsAndExtraFiles(t *testing.T) {
dir := t.TempDir()
m, err := BuildManifest(TargetSet{
Dirs: map[parser.AgentType][]string{
parser.AgentClaude: {filepath.Join(dir, "gone")},
},
ExtraFiles: []string{filepath.Join(dir, "gone.jsonl")},
})
require.NoError(t, err)
assert.Empty(t, m.Files)
}
func TestBuildManifestRejectsFileScopedAgents(t *testing.T) {
_, err := BuildManifest(TargetSet{
Dirs: map[parser.AgentType][]string{parser.AgentWindsurf: {"/srv/Windsurf/User"}},
Files: map[parser.AgentType][]string{
parser.AgentWindsurf: {"/srv/Windsurf/User/workspaceStorage/a/state.vscdb"},
},
})
require.Error(t, err)
assert.Contains(t, err.Error(), "file-scoped")
}