Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 55391c66d8 | |||
| 2287a8238c |
@@ -57,6 +57,11 @@ func main() {
|
|||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Validate reviewer-name: only safe characters allowed in sentinel
|
||||||
|
if err := validateReviewerName(*reviewerName); err != nil {
|
||||||
|
log.Fatalf("%v", err)
|
||||||
|
}
|
||||||
|
|
||||||
// Parse repo owner/name
|
// Parse repo owner/name
|
||||||
parts := strings.SplitN(*repo, "/", 2)
|
parts := strings.SplitN(*repo, "/", 2)
|
||||||
if len(parts) != 2 {
|
if len(parts) != 2 {
|
||||||
@@ -234,10 +239,6 @@ func main() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate reviewer-name: only safe characters allowed in sentinel
|
|
||||||
if err := validateReviewerName(*reviewerName); err != nil {
|
|
||||||
log.Fatalf("%v", err)
|
|
||||||
}
|
|
||||||
sentinel := fmt.Sprintf("<!-- review-bot:%s -->", *reviewerName)
|
sentinel := fmt.Sprintf("<!-- review-bot:%s -->", *reviewerName)
|
||||||
|
|
||||||
log.Printf("Posting review (event=%s)...", event)
|
log.Printf("Posting review (event=%s)...", event)
|
||||||
|
|||||||
@@ -134,3 +134,28 @@ func TestFormatMarkdown_Sentinel(t *testing.T) {
|
|||||||
t.Error("should not contain sentinel when reviewer name is empty")
|
t.Error("should not contain sentinel when reviewer name is empty")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestFormatMarkdown_RoleTitle(t *testing.T) {
|
||||||
|
result := &ReviewResult{
|
||||||
|
Verdict: "APPROVE",
|
||||||
|
Summary: "All good.",
|
||||||
|
Recommendation: "Merge it.",
|
||||||
|
}
|
||||||
|
|
||||||
|
// With reviewer name: should have title header
|
||||||
|
output := FormatMarkdown(result, "security")
|
||||||
|
if !strings.Contains(output, "# Security Review\n") {
|
||||||
|
t.Error("expected '# Security Review' header when reviewer name is set")
|
||||||
|
}
|
||||||
|
|
||||||
|
output2 := FormatMarkdown(result, "gpt")
|
||||||
|
if !strings.Contains(output2, "# Gpt Review\n") {
|
||||||
|
t.Error("expected '# Gpt Review' header")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Without reviewer name: no title header
|
||||||
|
output3 := FormatMarkdown(result, "")
|
||||||
|
if strings.Contains(output3, "# ") && strings.Contains(output3, " Review\n") {
|
||||||
|
t.Error("should not contain role title header when reviewer name is empty")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user