Skip to content

Commit c2335a8

Browse files
committed
LogSampled tests
1 parent 13f2b53 commit c2335a8

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

emf/logger_test.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,25 @@ func TestEmf(t *testing.T) {
195195
}
196196
}
197197

198+
func TestLogger_LogSampled(t *testing.T) {
199+
200+
t.Run("never", func(t *testing.T) {
201+
var buf bytes.Buffer
202+
emf.NewFor(&buf).Metric("foo", 1).LogSampled(0)
203+
if buf.Len() > 0 {
204+
t.Fatal("should be empty")
205+
}
206+
})
207+
208+
t.Run("always", func(t *testing.T) {
209+
var buf bytes.Buffer
210+
emf.NewFor(&buf).Metric("foo", 1).LogSampled(100)
211+
if buf.Len() == 0 {
212+
t.Fatal("should not be empty")
213+
}
214+
})
215+
}
216+
198217
func setenv(t *testing.T, env map[string]string) {
199218
for k, v := range env {
200219
err := os.Setenv(k, v)

0 commit comments

Comments
 (0)