Add Prepend* and HoldsData functions, remove error carrying

This commit is contained in:
Daniel 2021-06-24 10:59:55 +02:00
parent 52b0683882
commit adedde1310
2 changed files with 38 additions and 33 deletions

View file

@ -2,7 +2,6 @@ package container
import (
"bytes"
"errors"
"testing"
"github.com/safing/portbase/utils"
@ -82,38 +81,6 @@ func compareMany(t *testing.T, reference []byte, other ...[]byte) {
}
}
func TestContainerErrorHandling(t *testing.T) {
c1 := New(nil)
if c1.HasError() {
t.Error("should not have error")
}
c1.SetError(errors.New("test error"))
if !c1.HasError() {
t.Error("should have error")
}
c2 := New(append([]byte{0}, []byte("test error")...))
if c2.HasError() {
t.Error("should not have error")
}
c2.CheckError()
if !c2.HasError() {
t.Error("should have error")
}
if c2.Error().Error() != "test error" {
t.Errorf("error message mismatch, was %s", c2.Error())
}
}
func TestDataFetching(t *testing.T) {
c1 := New(utils.DuplicateBytes(testData))
data := c1.GetMax(1)