(t *testing.T)
| 124 | } |
| 125 | |
| 126 | func TestKnowledgePlugin_Metadata(t *testing.T) { |
| 127 | p := NewBuiltinKnowledgePlugin() |
| 128 | if p.Name() != "@knowledge" || p.Version() == "" || p.Path() != "" { |
| 129 | t.Errorf("metadata: name=%q version=%q path=%q", p.Name(), p.Version(), p.Path()) |
| 130 | } |
| 131 | if d := p.Description(); !strings.Contains(d, "knowledge bases") { |
| 132 | t.Errorf("Description = %q", d) |
| 133 | } |
| 134 | if u := p.Usage(); !strings.Contains(u, `"cmd":"search"`) { |
| 135 | t.Errorf("Usage must show the envelope example, got %q", u) |
| 136 | } |
| 137 | var schema struct { |
| 138 | Subcommands []struct { |
| 139 | Name string `json:"name"` |
| 140 | } `json:"subcommands"` |
| 141 | } |
| 142 | if err := json.Unmarshal([]byte(p.Schema()), &schema); err != nil { |
| 143 | t.Fatalf("Schema is not valid JSON: %v", err) |
| 144 | } |
| 145 | got := make([]string, 0, len(schema.Subcommands)) |
| 146 | for _, s := range schema.Subcommands { |
| 147 | got = append(got, s.Name) |
| 148 | } |
| 149 | if strings.Join(got, ",") != "search,get,toc,list" { |
| 150 | t.Errorf("Schema subcommands = %v", got) |
| 151 | } |
| 152 | } |
| 153 | |
| 154 | func TestKnowledgePlugin_NoAdapter(t *testing.T) { |
| 155 | SetKnowledgeAdapter(nil) |
nothing calls this directly
no test coverage detected