forked from chroe/gitlink-cli
57 lines
1.5 KiB
Go
57 lines
1.5 KiB
Go
package rules
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/gitlink-org/gitlink-cli/shortcuts/workflow"
|
|
)
|
|
|
|
func TestRegistryAllRegistered(t *testing.T) {
|
|
expected := []string{
|
|
"gitlink-triage",
|
|
"gitlink-health",
|
|
"gitlink-changelog",
|
|
"gitlink-review",
|
|
"gitlink-ci",
|
|
"gitlink-license",
|
|
"gitlink-repo",
|
|
}
|
|
for _, target := range expected {
|
|
if _, ok := workflow.RuleEngines[target]; !ok {
|
|
t.Errorf("rule engine not registered for target %q", target)
|
|
}
|
|
}
|
|
if len(workflow.RuleEngines) != len(expected) {
|
|
t.Fatalf("expected %d rule engines, got %d", len(expected), len(workflow.RuleEngines))
|
|
}
|
|
}
|
|
|
|
func TestHealthDispatchRule(t *testing.T) {
|
|
// contributor-ranking step should delegate to ContributorRankingRule.
|
|
resp, err := HealthDispatchRule(map[string]interface{}{}, "contributor-ranking")
|
|
if err != nil {
|
|
t.Fatalf("HealthDispatchRule failed: %v", err)
|
|
}
|
|
if resp == nil {
|
|
t.Fatal("expected non-nil response")
|
|
}
|
|
|
|
// health-report step should delegate to HealthReportRule.
|
|
resp, err = HealthDispatchRule(map[string]interface{}{}, "health-report")
|
|
if err != nil {
|
|
t.Fatalf("HealthDispatchRule for health-report failed: %v", err)
|
|
}
|
|
if resp == nil {
|
|
t.Fatal("expected non-nil response for health-report")
|
|
}
|
|
|
|
// repo-health step should delegate to HealthReportRule too.
|
|
resp, err = HealthDispatchRule(map[string]interface{}{}, "repo-health")
|
|
if err != nil {
|
|
t.Fatalf("HealthDispatchRule for repo-health failed: %v", err)
|
|
}
|
|
if resp == nil {
|
|
t.Fatal("expected non-nil response for repo-health")
|
|
}
|
|
}
|