40 lines
1.5 KiB
Go
40 lines
1.5 KiB
Go
//go:build integration
|
|
|
|
package main
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/novox/mesh-controller/internal/link"
|
|
)
|
|
|
|
func TestATrysOutcomeSetsNoStatusAndRegistersNothing(t *testing.T) {
|
|
said := &saidOnTheBus{}
|
|
checkEvents = said
|
|
defer func() { checkEvents = nil }()
|
|
for name, result := range map[string]link.BuildResult{
|
|
"a try": {ID: "build-1", Ref: "c0ffee", Checked: &link.CheckRequest{Owner: "novox", Repo: "a", Try: true},
|
|
Check: &link.CheckOutcome{Verdict: "pass", RepoCheck: &link.CheckLayer{Verdict: "fail", Summary: "failed"}}},
|
|
"a try that could not run": {ID: "build-2", Checked: &link.CheckRequest{Owner: "novox", Repo: "a", Try: true},
|
|
Failed: "cannot clone"},
|
|
// A build seat from before the mark echoes the ask without it: a check of no pull request and no
|
|
// group is still nobody's status.
|
|
"a try echoed by an older build seat": {ID: "build-3", Checked: &link.CheckRequest{Owner: "novox", Repo: "a"},
|
|
Check: &link.CheckOutcome{Verdict: "pass"}},
|
|
} {
|
|
if err := (builds{}).Built(context.Background(), result); err != nil {
|
|
t.Fatalf("%s: %v", name, err)
|
|
}
|
|
}
|
|
if len(said.events) != 0 {
|
|
t.Fatalf("a try's outcome was said for the forge: %v", said.events)
|
|
}
|
|
// A pull request's check is still said.
|
|
_ = (builds{}).Built(context.Background(), link.BuildResult{ID: "build-4", Checked: &link.CheckRequest{
|
|
Owner: "novox", Repo: "a", Number: 7}, Check: &link.CheckOutcome{Verdict: "pass"}})
|
|
if len(said.events) != 1 {
|
|
t.Fatalf("a pull request's check was said %d time(s)", len(said.events))
|
|
}
|
|
}
|