26 lines
542 B
Go
26 lines
542 B
Go
|
|
package event
|
||
|
|
|
||
|
|
import (
|
||
|
|
"testing"
|
||
|
|
)
|
||
|
|
|
||
|
|
func TestBufferCap(t *testing.T) {
|
||
|
|
u := &Uploader{buf: []SuspectedEvent{}}
|
||
|
|
for i := 0; i < 600; i++ {
|
||
|
|
u.buffer(SuspectedEvent{EventID: "test"})
|
||
|
|
}
|
||
|
|
if len(u.buf) != maxBuffer {
|
||
|
|
t.Errorf("buffer len: got %d want %d", len(u.buf), maxBuffer)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
func TestUploadError(t *testing.T) {
|
||
|
|
err := &UploadError{Fatal: true, Msg: "test error"}
|
||
|
|
if err.Error() != "test error" {
|
||
|
|
t.Errorf("Error(): got %q want %q", err.Error(), "test error")
|
||
|
|
}
|
||
|
|
if !err.Fatal {
|
||
|
|
t.Error("Fatal flag should be true")
|
||
|
|
}
|
||
|
|
}
|