Allow switching from limits-based to interest-based retention in stream update

Signed-off-by: Neil Twigg <neil@nats.io>
This commit is contained in:
Neil Twigg
2023-08-02 12:51:29 +01:00
parent 6eb77fd46b
commit d7f76da597
4 changed files with 153 additions and 10 deletions

View File

@@ -14,7 +14,6 @@
package server
import (
"bytes"
"fmt"
"math/rand"
"net/url"
@@ -112,17 +111,17 @@ func require_Error(t *testing.T, err error, expected ...error) {
t.Fatalf("Expected one of %v, got '%v'", expected, err)
}
func require_Equal(t *testing.T, a, b string) {
func require_Equal[T comparable](t *testing.T, a, b T) {
t.Helper()
if strings.Compare(a, b) != 0 {
t.Fatalf("require equal, but got: %v != %v", a, b)
if a != b {
t.Fatalf("require %T equal, but got: %v != %v", a, a, b)
}
}
func require_NotEqual(t *testing.T, a, b [32]byte) {
func require_NotEqual[T comparable](t *testing.T, a, b T) {
t.Helper()
if bytes.Equal(a[:], b[:]) {
t.Fatalf("require not equal, but got: %v != %v", a, b)
if a == b {
t.Fatalf("require %T not equal, but got: %v != %v", a, a, b)
}
}