-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugin_test.go
More file actions
70 lines (65 loc) · 2 KB
/
Copy pathplugin_test.go
File metadata and controls
70 lines (65 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package hebb
import (
"encoding/json"
"os"
"path/filepath"
"testing"
)
// Tests run with the working directory set to the package dir (the repo root),
// so the plugin/ paths are repo-relative.
func TestPluginManifestValid(t *testing.T) {
b, err := os.ReadFile(filepath.Join("plugin", ".claude-plugin", "plugin.json"))
if err != nil {
t.Fatalf("read plugin.json: %v", err)
}
var m struct {
Name string `json:"name"`
MCPServers string `json:"mcpServers"`
Skills string `json:"skills"`
Description string `json:"description"`
}
if err := json.Unmarshal(b, &m); err != nil {
t.Fatalf("plugin.json is not valid JSON: %v", err)
}
if m.Name != "hebb" {
t.Errorf("plugin name = %q, want hebb", m.Name)
}
if m.MCPServers == "" || m.Skills == "" {
t.Errorf("plugin.json should declare mcpServers and skills, got %+v", m)
}
}
func TestPluginMCPConfig(t *testing.T) {
b, err := os.ReadFile(filepath.Join("plugin", ".mcp.json"))
if err != nil {
t.Fatalf("read .mcp.json: %v", err)
}
var cfg struct {
MCPServers map[string]struct {
Command string `json:"command"`
Args []string `json:"args"`
Env map[string]string `json:"env"`
} `json:"mcpServers"`
}
if err := json.Unmarshal(b, &cfg); err != nil {
t.Fatalf(".mcp.json is not valid JSON: %v", err)
}
srv, ok := cfg.MCPServers["hebb"]
if !ok {
t.Fatalf("plugin .mcp.json missing the hebb server")
}
if srv.Command != "hebb" {
t.Errorf("command = %q, want hebb", srv.Command)
}
if len(srv.Args) != 1 || srv.Args[0] != "mcp" {
t.Errorf("args = %v, want [mcp]", srv.Args)
}
// The vault is resolved from the opened project via this env var.
if srv.Env["HEBB_VAULT"] != "${CLAUDE_PROJECT_DIR}" {
t.Errorf("env HEBB_VAULT = %q, want ${CLAUDE_PROJECT_DIR}", srv.Env["HEBB_VAULT"])
}
}
func TestPluginShipsSkill(t *testing.T) {
if _, err := os.Stat(filepath.Join("plugin", "skills", "vault-ingest", "SKILL.md")); err != nil {
t.Errorf("plugin should ship the vault-ingest skill: %v", err)
}
}