Skip to content

Commit

Permalink
Include key size in ARGS_COMBINED_SIZE (#756)
Browse files Browse the repository at this point in the history
Co-authored-by: José Carlos Chávez <[email protected]>
  • Loading branch information
anuraaga and jcchavezs authored Apr 12, 2023
1 parent 57b42eb commit 6f11f53
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion internal/collections/sized.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func (c *SizeCollection) size() int {
// we iterate over d
for _, data := range d.data {
for _, v := range data {
i += len(v.value)
i += len(v.key) + len(v.value)
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions internal/collections/sized_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@ func TestSizedCollection(t *testing.T) {
t.Errorf("want %s, have %s", want, have)
}
c1.Set("key1", []string{"value1", "value2"})
assertValuesMatch(t, proxy.FindAll(), "12")
if want, have := "ARGS_COMBINED_SIZE: 12", proxy.String(); want != have {
assertValuesMatch(t, proxy.FindAll(), "20")
if want, have := "ARGS_COMBINED_SIZE: 20", proxy.String(); want != have {
t.Errorf("want %s, have %s", want, have)
}
c1.Set("key2", []string{"value2"})
assertValuesMatch(t, proxy.FindAll(), "18")
if want, have := "ARGS_COMBINED_SIZE: 18", proxy.String(); want != have {
assertValuesMatch(t, proxy.FindAll(), "30")
if want, have := "ARGS_COMBINED_SIZE: 30", proxy.String(); want != have {
t.Errorf("want %s, have %s", want, have)
}
c2.Set("key3", []string{"value3"})
assertValuesMatch(t, proxy.FindAll(), "24")
if want, have := "ARGS_COMBINED_SIZE: 24", proxy.String(); want != have {
assertValuesMatch(t, proxy.FindAll(), "40")
if want, have := "ARGS_COMBINED_SIZE: 40", proxy.String(); want != have {
t.Errorf("want %s, have %s", want, have)
}
}

0 comments on commit 6f11f53

Please sign in to comment.