MCPcopy Create free account
hub / github.com/AdRoll/baker / TestLogLineSetPanic

Function TestLogLineSetPanic

logline_test.go:629–675  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

627}
628
629func TestLogLineSetPanic(t *testing.T) {
630 t.Run("index out of range", func(t *testing.T) {
631 fidx := LogLineNumFields + NumFieldsBaker
632
633 defer func() {
634 if r := recover(); r == nil {
635 t.Errorf("Set(%d) should panic", fidx)
636 }
637 }()
638
639 ll := LogLine{FieldSeparator: ','}
640 ll.Set(fidx, []byte("value"))
641 })
642
643 t.Run("max fields written", func(t *testing.T) {
644 var fidx FieldIndex
645
646 defer func() {
647 if r := recover(); r != nil {
648 t.Errorf("Set(%d) should not panic: %q", fidx, r)
649 }
650 }()
651
652 ll := LogLine{FieldSeparator: ','}
653 // Maximum of 254 changed fields.
654 for i := 0; i < 255; i++ {
655 fidx = FieldIndex(i)
656 ll.Set(fidx, []byte("value"))
657 }
658 })
659
660 t.Run("too many field written", func(t *testing.T) {
661 defer func() {
662 if r := recover(); r == nil {
663 t.Errorf("Set(%d) should panic", 1000)
664 }
665 }()
666
667 ll := LogLine{FieldSeparator: ','}
668 // Maximum of 254 changed fields.
669 for i := 0; i < 255; i++ {
670 ll.Set(FieldIndex(i), []byte("value"))
671 }
672 // One more.
673 ll.Set(FieldIndex(1000), []byte("value"))
674 })
675}
676
677func TestLogLineCopy(t *testing.T) {
678 t.Run("nil", func(t *testing.T) {

Callers

nothing calls this directly

Calls 3

SetMethod · 0.95
FieldIndexTypeAlias · 0.85
RunMethod · 0.65

Tested by

no test coverage detected