f99010fae1
Desktop Artifacts / Desktop Build (Linux) (push) Waiting to run
Desktop Artifacts / Desktop Build (Windows) (push) Waiting to run
Desktop Artifacts / Desktop Build (Linux (arm64)) (push) Waiting to run
Desktop Artifacts (macOS) / Desktop Build (macOS (aarch64)) (push) Waiting to run
Desktop Artifacts (macOS) / Desktop Build (macOS (x86_64)) (push) Waiting to run
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
92 lines
2.0 KiB
Go
92 lines
2.0 KiB
Go
package sync
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
"go.kenn.io/agentsview/internal/parser"
|
|
)
|
|
|
|
func TestClassifyOnePath_Cortex(t *testing.T) {
|
|
dir := t.TempDir()
|
|
uuid := "11111111-2222-3333-4444-555555555555"
|
|
|
|
// Create session .json and companion .history.jsonl.
|
|
jsonPath := filepath.Join(dir, uuid+".json")
|
|
jsonlPath := filepath.Join(dir, uuid+".history.jsonl")
|
|
require.NoError(t, os.WriteFile(jsonPath, []byte("{}"), 0o644))
|
|
require.NoError(t, os.WriteFile(jsonlPath, []byte("{}"), 0o644))
|
|
|
|
eng := &Engine{
|
|
db: openTestDB(t),
|
|
agentDirs: map[parser.AgentType][]string{
|
|
parser.AgentCortex: {dir},
|
|
},
|
|
providerFactories: providerFactoryMap(parser.ProviderFactories()),
|
|
providerMigrationModes: map[parser.AgentType]parser.ProviderMigrationMode{
|
|
parser.AgentCortex: parser.ProviderMigrationProviderAuthoritative,
|
|
},
|
|
}
|
|
|
|
tests := []struct {
|
|
name string
|
|
path string
|
|
want bool
|
|
agent parser.AgentType
|
|
retPath string // expected Path in DiscoveredFile
|
|
}{
|
|
{
|
|
name: "uuid.json classified",
|
|
path: jsonPath,
|
|
want: true,
|
|
agent: parser.AgentCortex,
|
|
retPath: jsonPath,
|
|
},
|
|
{
|
|
name: "history.jsonl remaps to .json",
|
|
path: jsonlPath,
|
|
want: true,
|
|
agent: parser.AgentCortex,
|
|
retPath: jsonPath,
|
|
},
|
|
{
|
|
name: "backup file ignored",
|
|
path: filepath.Join(
|
|
dir, uuid+".back.12345.json",
|
|
),
|
|
want: false,
|
|
},
|
|
{
|
|
name: "nested path ignored",
|
|
path: filepath.Join(
|
|
dir, "subdir", uuid+".json",
|
|
),
|
|
want: false,
|
|
},
|
|
{
|
|
name: "unrelated file ignored",
|
|
path: filepath.Join(dir, "readme.txt"),
|
|
want: false,
|
|
},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
files := eng.classifyPaths([]string{tt.path})
|
|
if !tt.want {
|
|
assert.Empty(t, files)
|
|
return
|
|
}
|
|
require.Len(t, files, 1)
|
|
got := files[0]
|
|
if tt.want {
|
|
assert.Equal(t, tt.agent, got.Agent)
|
|
assert.Equal(t, tt.retPath, got.Path)
|
|
}
|
|
})
|
|
}
|
|
}
|