package cmd import ( "strings" "testing" ) func TestBuildPRDescribeMessages(t *testing.T) { tests := []struct { name string diff string sysCheck string usrCheck []string }{ { name: "branch with changes", diff: "diff --git a/cmd/new.go b/cmd/new.go\n+package cmd", sysCheck: "PR", usrCheck: []string{"Diff:", "diff --git a/cmd/new.go"}, }, { name: "empty diff", diff: "", sysCheck: "PR", usrCheck: []string{"Diff:"}, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { msgs := buildPRDescribeMessages(tt.diff) if len(msgs) != 2 { t.Fatalf("expected 2 messages, got %d", len(msgs)) } if msgs[0]["role"] != "system" { t.Errorf("first message role = %q, want %q", msgs[0]["role"], "system") } if msgs[1]["role"] != "user" { t.Errorf("second message role = %q, want %q", msgs[1]["role"], "user") } if !strings.Contains(msgs[0]["content"], tt.sysCheck) { t.Errorf("system prompt missing %q; got: %s", tt.sysCheck, msgs[0]["content"]) } for _, check := range tt.usrCheck { if !strings.Contains(msgs[1]["content"], check) { t.Errorf("user prompt missing %q", check) } } }) } }