fixes
This commit is contained in:
1 parent
c8cc0fb28a
commit
e790c02d59
16 files changed
+659
-15
No files matched your search
@@ -0,0 +1,50 @@
|
||||
package issues
|
||||
|
||||
import (
|
||||
"context"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestTriagePersistsAcrossRestart(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), "status.json")
|
||||
store, _ := NewFileStatusStore(path)
|
||||
tr := NewTracker()
|
||||
if err := tr.SetStatusStore(context.Background(), store); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
tr.Record("span", "svc", "boom", Sample{Timestamp: 1})
|
||||
id := Fingerprint("span", "svc", NormalizeTitle("boom"))
|
||||
if _, ok := tr.SetStatus(id, StatusIgnored); !ok {
|
||||
t.Fatal("set status")
|
||||
}
|
||||
time.Sleep(100 * time.Millisecond) // async save
|
||||
|
||||
// "Restart": fresh tracker, same file.
|
||||
store2, err := NewFileStatusStore(path)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
tr2 := NewTracker()
|
||||
if err := tr2.SetStatusStore(context.Background(), store2); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
tr2.Record("span", "svc", "boom", Sample{Timestamp: 2})
|
||||
got, _ := tr2.Get(id)
|
||||
if got.Status != StatusIgnored {
|
||||
t.Fatalf("status after restart = %q, want ignored", got.Status)
|
||||
}
|
||||
}
|
||||
|
||||
func TestResolvedIssueRegresses(t *testing.T) {
|
||||
tr := NewTracker()
|
||||
tr.Record("span", "svc", "boom", Sample{Timestamp: 1})
|
||||
id := Fingerprint("span", "svc", NormalizeTitle("boom"))
|
||||
tr.SetStatus(id, StatusResolved)
|
||||
tr.Record("span", "svc", "boom", Sample{Timestamp: 5})
|
||||
got, _ := tr.Get(id)
|
||||
if got.Status != StatusOpen || got.RegressedAt != 5 {
|
||||
t.Fatalf("got status=%q regressedAt=%d", got.Status, got.RegressedAt)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user