Skip to content
Snippets Groups Projects
Commit b0e268db authored by Benjamin Wenger's avatar Benjamin Wenger
Browse files

flipped some error messages that were wrong

parent b2f9eb23
No related branches found
No related tags found
No related merge requests found
......@@ -188,12 +188,12 @@ func (rb *Buff) getById(id int) (interface{}, error) {
// Check it's not before our first known id
if id < rb.oldest {
return nil, errors.Errorf("requested ID %d is lower than oldest id %d", id, rb.newest)
return nil, errors.Errorf("requested ID %d is lower than oldest id %d", id, rb.oldest)
}
// Check it's not after our last known id
if id > rb.newest {
return nil, errors.Errorf("requested id %d is higher than most recent id %d", id, rb.oldest)
return nil, errors.Errorf("requested id %d is higher than most recent id %d", id, rb.newest)
}
return rb.buff[id%rb.count], nil
......
......@@ -117,7 +117,7 @@ func TestBuff_Push(t *testing.T) {
// Test ID upsert on ringbuff (bulk of cases)
func TestBuff_UpsertById(t *testing.T) {
rb := setup()
rb := NewBuff(5)
v := 15
err := rb.UpsertById(v, &v)
if err != nil {
......@@ -127,10 +127,11 @@ func TestBuff_UpsertById(t *testing.T) {
t.Error("Failed to get correct ID")
}
val, _ := rb.GetById(7)
val, err := rb.GetById(7)
if val != nil {
t.Errorf("Should have gotten nil value for id 7")
}
fmt.Println(err.Error())
v = 14
err = rb.UpsertById(v, &v)
if err != nil {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment