Files
kenn-io--agentsview/internal/parser/skill_inference_nonwindows_test.go
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

41 lines
1.2 KiB
Go

//go:build !windows
package parser
import (
"os"
"path/filepath"
"syscall"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestSkillNameFromFrontmatterRejectsSymlink(t *testing.T) {
real := writeTestSkill(t, "index", "data-analytics:index")
// A SKILL.md symlink pointing at the real skill must not have
// its frontmatter read; resolution falls back to the parent
// directory name of the symlink path instead.
linkDir := filepath.Join(t.TempDir(), "evil")
require.NoError(t, os.MkdirAll(linkDir, 0o755))
link := filepath.Join(linkDir, "SKILL.md")
require.NoError(t, os.Symlink(real, link))
assert.Equal(t, "evil", skillNameFromPath(link, ""))
}
func TestSkillNameFromFrontmatterRejectsNonRegularFile(t *testing.T) {
dir := filepath.Join(t.TempDir(), "qa")
require.NoError(t, os.MkdirAll(dir, 0o755))
fifo := filepath.Join(dir, "SKILL.md")
if err := syscall.Mkfifo(fifo, 0o644); err != nil {
t.Skipf("mkfifo unsupported: %v", err)
}
// Must not block on the FIFO open and must not read frontmatter;
// resolution falls back to the parent directory name.
assert.Equal(t, "qa", skillNameFromPath(fifo, ""))
}