Files
task-master/internal/mcp/token_test.go
T
skrueckenandCursor 846bb31dc9
CI / test-and-build (push) Failing after 1m25s
CI / demo (push) Skipped
Add stdio MCP server for token-scoped ticket access.
Expose tm mcp tools against the local daemon, document agent setup, and
ignore workspace .tm_token files.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-01 16:56:11 +01:00

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")
}
}