monitor a good

Former-commit-id: 5a37bfdfe208d3d1a71e6b4924209d0c8e6f53a0
This commit is contained in:
bel
2019-06-21 21:59:56 -06:00
parent 90a31495c9
commit 730cf1e15a
32 changed files with 542 additions and 2983 deletions

49
monitor/queue_test.go Normal file
View File

@@ -0,0 +1,49 @@
package monitor
import (
"testing"
"time"
)
func initQueue() {
initItem()
}
func TestQueue(t *testing.T) {
initQueue()
q := newQueue()
if i := q.Peek(); i != nil {
t.Error(i)
}
i := &Item{Key: "k"}
q.Push(i)
if i := q.Peek(); i.Key != "k" {
t.Error(i)
} else if j := q.Pop(); i != j {
t.Error(j)
} else if j.Key != "k" {
t.Error(j)
}
}
func TestQueuePriority(t *testing.T) {
initQueue()
q := newQueue()
i, _ := NewItem("iQueuePriority", time.Second)
j, _ := NewItem("jQueuePriority", time.Hour)
q.Push(i)
q.Push(j)
if k := q.Peek(); k.Key != "iQueuePriority" {
t.Errorf("compare is backwards")
}
if q.Len() != 2 {
t.Error(q.Len())
}
}