MCPcopy Index your code
hub / github.com/coder/coder / TestParseSkillFrontmatter

Function TestParseSkillFrontmatter

codersdk/workspacesdk/frontmatter_test.go:12–193  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

10)
11
12func TestParseSkillFrontmatter(t *testing.T) {
13 t.Parallel()
14
15 t.Run("Basic", func(t *testing.T) {
16 t.Parallel()
17 name, desc, body, err := workspacesdk.ParseSkillFrontmatter(
18 "---\nname: my-skill\ndescription: Does a thing\n---\nBody text here.\n",
19 )
20 require.NoError(t, err)
21 require.Equal(t, "my-skill", name)
22 require.Equal(t, "Does a thing", desc)
23 require.Equal(t, "Body text here.", body)
24 })
25
26 t.Run("QuotedValues", func(t *testing.T) {
27 t.Parallel()
28 name, desc, _, err := workspacesdk.ParseSkillFrontmatter(
29 "---\nname: \"quoted-name\"\ndescription: 'single-quoted'\n---\n",
30 )
31 require.NoError(t, err)
32 require.Equal(t, "quoted-name", name)
33 require.Equal(t, "single-quoted", desc)
34 })
35
36 t.Run("EscapedDoubleQuotedValue", func(t *testing.T) {
37 t.Parallel()
38 _, desc, _, err := workspacesdk.ParseSkillFrontmatter(
39 "---\nname: escaped\ndescription: \"Review \\\"critical\\\" C:\\\\paths.\"\n---\nBody\n",
40 )
41 require.NoError(t, err)
42 require.Equal(t, "Review \"critical\" C:\\paths.", desc)
43 })
44
45 t.Run("FoldedDescription", func(t *testing.T) {
46 t.Parallel()
47 name, desc, body, err := workspacesdk.ParseSkillFrontmatter(
48 strings.Join([]string{
49 "---",
50 "name: brainstorming",
51 "description: >",
52 " Use before any creative work: features, components, functionality changes,",
53 " or behavior modifications. Turns ideas into approved designs through",
54 " collaborative dialog. Hard gate: no implementation action until the",
55 " design is presented and approved.",
56 "",
57 "---",
58 "Use this skill.",
59 }, "\n"),
60 )
61 require.NoError(t, err)
62 require.Equal(t, "brainstorming", name)
63 require.Equal(t, strings.Join([]string{
64 "Use before any creative work: features, components, functionality changes,",
65 "or behavior modifications. Turns ideas into approved designs through",
66 "collaborative dialog. Hard gate: no implementation action until the",
67 "design is presented and approved.",
68 }, " "), desc)
69 require.Equal(t, "Use this skill.", body)

Callers

nothing calls this directly

Calls 5

ParseSkillFrontmatterFunction · 0.92
RunMethod · 0.65
EqualMethod · 0.45
EmptyMethod · 0.45
ContainsMethod · 0.45

Tested by

no test coverage detected