mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-19 07:01:02 +01:00
d5c180e680
It is better developing vmctl tool in VictoriaMetrics repository, so it could be released together with the rest of vmutils tools such as vmalert, vmagent, vmbackup, vmrestore and vmauth.
35 lines
662 B
Go
35 lines
662 B
Go
package prometheus
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestInRange(t *testing.T) {
|
|
testCases := []struct {
|
|
filterMin, filterMax int64
|
|
blockMin, blockMax int64
|
|
expected bool
|
|
}{
|
|
{0, 0, 1, 2, true},
|
|
{0, 3, 1, 2, true},
|
|
{0, 3, 4, 5, false},
|
|
{3, 0, 1, 2, false},
|
|
{3, 0, 2, 4, true},
|
|
{3, 10, 1, 2, false},
|
|
{3, 10, 1, 4, true},
|
|
{3, 10, 5, 9, true},
|
|
{3, 10, 9, 12, true},
|
|
{3, 10, 12, 15, false},
|
|
}
|
|
for _, tc := range testCases {
|
|
f := filter{
|
|
min: tc.filterMin,
|
|
max: tc.filterMax,
|
|
}
|
|
got := f.inRange(tc.blockMin, tc.blockMax)
|
|
if got != tc.expected {
|
|
t.Fatalf("got %v; expected %v: %v", got, tc.expected, tc)
|
|
}
|
|
}
|
|
}
|