Expose tm mcp tools against the local daemon, document agent setup, and ignore workspace .tm_token files. Co-authored-by: Cursor <cursoragent@cursor.com>
44 lines
950 B
Go
44 lines
950 B
Go
package mcp
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
)
|
|
|
|
func TestParseAndFindTokenFile(t *testing.T) {
|
|
root := t.TempDir()
|
|
sub := filepath.Join(root, "a", "b")
|
|
if err := os.MkdirAll(sub, 0o755); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
path := filepath.Join(root, ".tm_token")
|
|
content := "# comment\nproject=inbox\ntoken=tm_mcp_abc\n"
|
|
if err := os.WriteFile(path, []byte(content), 0o600); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
tf, err := FindTokenFile(sub)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if tf.Project != "inbox" || tf.Token != "tm_mcp_abc" {
|
|
t.Fatalf("got %+v", tf)
|
|
}
|
|
|
|
_, err = FindTokenFile(t.TempDir())
|
|
if err == nil {
|
|
t.Fatal("expected missing token error")
|
|
}
|
|
}
|
|
|
|
func TestParseTokenFileIncomplete(t *testing.T) {
|
|
path := filepath.Join(t.TempDir(), ".tm_token")
|
|
if err := os.WriteFile(path, []byte("project=only\n"), 0o600); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if _, err := ParseTokenFile(path); err == nil {
|
|
t.Fatal("expected error")
|
|
}
|
|
}
|