fix
This commit is contained in:
1 parent
49c6c6cc76
commit
6dc2785f71
4 files changed
+117
-24
No files matched your search
@@ -96,10 +96,20 @@ func TestScannerPagesOnceThenOngoing(t *testing.T) {
|
||||
if len(fourth.Recovered) != 1 || fourth.Recovered[0].Service != "checkout" {
|
||||
t.Fatalf("expected checkout in recovered, got %+v", fourth.Recovered)
|
||||
}
|
||||
// The last issue stays on the display as resolved instead of ALL CLEAR.
|
||||
if len(fourth.Resolved) != 1 || fourth.Resolved[0].alert.Spike.Service != "checkout" {
|
||||
t.Fatalf("expected checkout kept as resolved, got %+v", fourth.Resolved)
|
||||
}
|
||||
if got := fourth.Resolved[0].resolvedAt; !got.Equal(fourth.WindowEnd) {
|
||||
t.Fatalf("resolvedAt should be the window that stopped firing, got %v want %v", got, fourth.WindowEnd)
|
||||
}
|
||||
again := sc.Scan(context.Background(), base.Add(4*time.Minute))
|
||||
if len(again.Recovered) != 0 {
|
||||
t.Fatalf("recovery should be reported once, got %+v", again.Recovered)
|
||||
}
|
||||
if len(again.Resolved) != 1 || !again.Resolved[0].resolvedAt.Equal(fourth.Resolved[0].resolvedAt) {
|
||||
t.Fatalf("resolved issue should persist with a stable resolved time, got %+v", again.Resolved)
|
||||
}
|
||||
}
|
||||
|
||||
func TestScannerAllClearAndError(t *testing.T) {
|
||||
@@ -108,6 +118,9 @@ func TestScannerAllClearAndError(t *testing.T) {
|
||||
if len(empty.Issues) != 0 || empty.Err != nil {
|
||||
t.Fatalf("empty loader should yield a clean snapshot, got %+v", empty)
|
||||
}
|
||||
if len(empty.Resolved) != 0 {
|
||||
t.Fatalf("a fresh scanner has no last issue to keep, got %+v", empty.Resolved)
|
||||
}
|
||||
|
||||
sc.load = func(context.Context, time.Time, time.Time) ([]features.Event, error) {
|
||||
return nil, context.DeadlineExceeded
|
||||
@@ -204,6 +217,22 @@ func TestRenderSnapshotAllClear(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestRenderSnapshotKeepsResolvedIssue(t *testing.T) {
|
||||
now := time.Date(2025, 6, 1, 12, 45, 0, 0, time.UTC)
|
||||
snap, o := cardAt(t, 1)
|
||||
resolved := snap.Issues[0]
|
||||
resolved.resolvedAt = now
|
||||
snap.Issues = nil
|
||||
snap.Resolved = []issueView{resolved}
|
||||
out := renderSnapshot(snap, o)
|
||||
if strings.Contains(out, "ALL CLEAR") {
|
||||
t.Fatalf("a resolved issue should replace the ALL CLEAR panel:\n%s", out)
|
||||
}
|
||||
if !strings.Contains(out, "RESOLVED") || !strings.Contains(out, "checkout") {
|
||||
t.Fatalf("dashboard should keep the last issue as resolved:\n%s", out)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRenderSnapshotScanError(t *testing.T) {
|
||||
snap := snapshot{Err: context.DeadlineExceeded}
|
||||
out := renderSnapshot(snap, snapshotOptions{Width: 200, Height: 12, Title: "otel issues", Now: time.Now()})
|
||||
|
||||
Reference in new issue
Block a user