Add YouTrack pull/push sync with project settings and time tracking.
Wire manual Y menu and CLI sync for issues and work items, persist per-project credentials, and keep local edits until an explicit push. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
package project_test
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"task/internal/project"
|
||||
)
|
||||
|
||||
func TestMetaSaveLoad(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
store := project.NewDirStore(dir)
|
||||
if err := store.Ensure("inbox"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
meta := project.Meta{
|
||||
YouTrack: &project.YouTrack{
|
||||
BaseURL: "https://yt.example.com",
|
||||
Token: "perm:secret",
|
||||
ProjectKey: "PROJ",
|
||||
},
|
||||
}
|
||||
if err := store.SaveMeta("inbox", meta); err != nil {
|
||||
t.Fatalf("SaveMeta: %v", err)
|
||||
}
|
||||
|
||||
path := filepath.Join(dir, "projects", "inbox", "meta.json")
|
||||
st, err := os.Stat(path)
|
||||
if err != nil {
|
||||
t.Fatalf("stat: %v", err)
|
||||
}
|
||||
if st.Mode().Perm()&0o077 != 0 {
|
||||
t.Fatalf("meta permissions too open: %o", st.Mode().Perm())
|
||||
}
|
||||
|
||||
got, err := store.LoadMeta("inbox")
|
||||
if err != nil {
|
||||
t.Fatalf("LoadMeta: %v", err)
|
||||
}
|
||||
if got.YouTrack == nil || got.YouTrack.Token != "perm:secret" || got.YouTrack.ProjectKey != "PROJ" {
|
||||
t.Fatalf("got %+v", got.YouTrack)
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadMetaMissing(t *testing.T) {
|
||||
store := project.NewDirStore(t.TempDir())
|
||||
got, err := store.LoadMeta("missing")
|
||||
if err != nil {
|
||||
t.Fatalf("LoadMeta: %v", err)
|
||||
}
|
||||
if got.YouTrack != nil {
|
||||
t.Fatalf("expected empty meta, got %+v", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestYouTrackConfiguredAndQuery(t *testing.T) {
|
||||
y := project.YouTrack{BaseURL: "https://x", Token: "t", ProjectKey: "ABC"}
|
||||
if !y.Configured() {
|
||||
t.Fatal("expected configured")
|
||||
}
|
||||
if y.IssueQuery() != "project: ABC" {
|
||||
t.Fatalf("query = %q", y.IssueQuery())
|
||||
}
|
||||
y.Query = "Assignee: me"
|
||||
if y.IssueQuery() != "Assignee: me" {
|
||||
t.Fatalf("query = %q", y.IssueQuery())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user