Skip to content

Commit

Permalink
add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mehrdadrad committed Oct 30, 2020
1 parent 532c6aa commit 9e1a1a1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions status/status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func TestMetricsFunc(t *testing.T) {
mg.Dec()
assert.Equal(t, uint64(0), mg.Value)
mg.Set(55)
assert.Equal(t, uint64(55), mg.Value)
assert.Equal(t, uint64(55), mg.Get())

mc := NewCounter("test_errors_total", "")
assert.Equal(t, uint64(0), mc.Value)
Expand All @@ -102,7 +102,7 @@ func TestMetricsFunc(t *testing.T) {
mc.Dec()
assert.Equal(t, uint64(1), mc.Value)
mc.Set(5)
assert.Equal(t, uint64(1), mc.Value)
assert.Equal(t, uint64(1), mc.Get())

}

Expand Down
15 changes: 15 additions & 0 deletions telemetry/juniper/jti/jti_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,21 @@ func TestGetLabelsNumber(t *testing.T) {
assert.Equal(t, expectedLabels, labels)
}

func TestGetValue(t *testing.T) {
kv := jpb.KeyValue{Value: &jpb.KeyValue_DoubleValue{DoubleValue: 5.5}}
assert.Equal(t, 5.5, getValue(&kv))
kv = jpb.KeyValue{Value: &jpb.KeyValue_IntValue{IntValue: 5}}
assert.Equal(t, int64(5), getValue(&kv))
kv = jpb.KeyValue{Value: &jpb.KeyValue_SintValue{SintValue: 5}}
assert.Equal(t, int64(5), getValue(&kv))
kv = jpb.KeyValue{Value: &jpb.KeyValue_BytesValue{BytesValue: []byte("test")}}
assert.Equal(t, []byte("test"), getValue(&kv))
}

func TestVersion(t *testing.T) {
assert.Equal(t, jtiVersion, Version())
}

func BenchmarkGetLabels(b *testing.B) {
r := new(bytes.Buffer)
w := new(bytes.Buffer)
Expand Down

0 comments on commit 9e1a1a1

Please sign in to comment.