build(deps): Bump pgregory.net/rapid from 0.4.8 to 0.5.2 (#13096)

* build(deps): Bump pgregory.net/rapid from 0.4.8 to 0.5.2

Bumps [pgregory.net/rapid](https://github.com/flyingmutant/rapid) from 0.4.8 to 0.5.2.
- [Release notes](https://github.com/flyingmutant/rapid/releases)
- [Commits](https://github.com/flyingmutant/rapid/compare/v0.4.8...v0.5.2)

---
updated-dependencies:
- dependency-name: pgregory.net/rapid
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* fix group tests

* update orm to 0.5.2

* Fix some tests

* finish upgrading orm

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Amaury M <1293565+amaurym@users.noreply.github.com>
Co-authored-by: Aaron Craelius <aaronc@users.noreply.github.com>
Co-authored-by: Julien Robert <julien@rbrt.fr>
This commit is contained in:
dependabot[bot]
2022-08-30 20:17:15 +00:00
committed by GitHub
co-authored by Amaury M Aaron Craelius Julien Robert
parent d07b28d2bf
commit 084e129fcf
19 changed files with 102 additions and 99 deletions
+5 -5
View File
@@ -31,7 +31,7 @@ func testCodec(t *testing.T, spec testutil.TestFieldSpec) {
})
}
func testCodecNT(t *testing.T, fname protoreflect.Name, generator *rapid.Generator, nonTerminal bool) {
func testCodecNT(t *testing.T, fname protoreflect.Name, generator *rapid.Generator[any], nonTerminal bool) {
cdc, err := testutil.MakeTestCodec(fname, nonTerminal)
assert.NilError(t, err)
rapid.Check(t, func(t *rapid.T) {
@@ -98,8 +98,8 @@ func TestCompactUInt32(t *testing.T) {
// randomized tests
rapid.Check(t, func(t *rapid.T) {
x := rapid.Uint32().Draw(t, "x").(uint32)
y := rapid.Uint32().Draw(t, "y").(uint32)
x := rapid.Uint32().Draw(t, "x")
y := rapid.Uint32().Draw(t, "y")
bx := ormfield.EncodeCompactUint32(x)
by := ormfield.EncodeCompactUint32(y)
@@ -146,8 +146,8 @@ func TestCompactUInt64(t *testing.T) {
// randomized tests
rapid.Check(t, func(t *rapid.T) {
x := rapid.Uint64().Draw(t, "x").(uint64)
y := rapid.Uint64().Draw(t, "y").(uint64)
x := rapid.Uint64().Draw(t, "x")
y := rapid.Uint64().Draw(t, "y")
bx := ormfield.EncodeCompactUint64(x)
by := ormfield.EncodeCompactUint64(y)
+4 -4
View File
@@ -15,9 +15,9 @@ import (
func TestIndexKeyCodec(t *testing.T) {
rapid.Check(t, func(t *rapid.T) {
idxPartCdc := testutil.TestKeyCodecGen(1, 5).Draw(t, "idxPartCdc").(testutil.TestKeyCodec)
pkCodec := testutil.TestKeyCodecGen(1, 5).Draw(t, "pkCdc").(testutil.TestKeyCodec)
prefix := rapid.SliceOfN(rapid.Byte(), 0, 5).Draw(t, "prefix").([]byte)
idxPartCdc := testutil.TestKeyCodecGen(1, 5).Draw(t, "idxPartCdc")
pkCodec := testutil.TestKeyCodecGen(1, 5).Draw(t, "pkCdc")
prefix := rapid.SliceOfN(rapid.Byte(), 0, 5).Draw(t, "prefix")
messageType := (&testpb.ExampleTable{}).ProtoReflect().Type()
indexKeyCdc, err := ormkv.NewIndexKeyCodec(
prefix,
@@ -27,7 +27,7 @@ func TestIndexKeyCodec(t *testing.T) {
)
assert.NilError(t, err)
for i := 0; i < 100; i++ {
a := testutil.GenA.Draw(t, fmt.Sprintf("a%d", i)).(*testpb.ExampleTable)
a := testutil.GenA.Draw(t, fmt.Sprintf("a%d", i))
key := indexKeyCdc.GetKeyValues(a.ProtoReflect())
pk := pkCodec.Codec.GetKeyValues(a.ProtoReflect())
idx1 := &ormkv.IndexKeyEntry{
+1 -1
View File
@@ -17,7 +17,7 @@ import (
func TestKeyCodec(t *testing.T) {
rapid.Check(t, func(t *rapid.T) {
key := testutil.TestKeyCodecGen(0, 5).Draw(t, "key").(testutil.TestKeyCodec)
key := testutil.TestKeyCodecGen(0, 5).Draw(t, "key")
for i := 0; i < 100; i++ {
keyValues := key.Draw(t, "values")
+2 -2
View File
@@ -17,7 +17,7 @@ import (
func TestPrimaryKeyCodec(t *testing.T) {
rapid.Check(t, func(t *rapid.T) {
keyCodec := testutil.TestKeyCodecGen(0, 5).Draw(t, "keyCodec").(testutil.TestKeyCodec)
keyCodec := testutil.TestKeyCodecGen(0, 5).Draw(t, "keyCodec")
pkCodec, err := ormkv.NewPrimaryKeyCodec(
keyCodec.Codec.Prefix(),
(&testpb.ExampleTable{}).ProtoReflect().Type(),
@@ -26,7 +26,7 @@ func TestPrimaryKeyCodec(t *testing.T) {
)
assert.NilError(t, err)
for i := 0; i < 100; i++ {
a := testutil.GenA.Draw(t, fmt.Sprintf("a%d", i)).(*testpb.ExampleTable)
a := testutil.GenA.Draw(t, fmt.Sprintf("a%d", i))
key := keyCodec.Codec.GetKeyValues(a.ProtoReflect())
pk1 := &ormkv.PrimaryKeyEntry{
TableName: aFullName,
+2 -2
View File
@@ -14,7 +14,7 @@ import (
func TestSeqCodec(t *testing.T) {
rapid.Check(t, func(t *rapid.T) {
prefix := rapid.SliceOfN(rapid.Byte(), 0, 5).Draw(t, "prefix").([]byte)
prefix := rapid.SliceOfN(rapid.Byte(), 0, 5).Draw(t, "prefix")
typ := (&testpb.ExampleTable{}).ProtoReflect().Type()
tableName := typ.Descriptor().FullName()
cdc := ormkv.NewSeqCodec(typ, prefix)
@@ -27,7 +27,7 @@ func TestSeqCodec(t *testing.T) {
assert.NilError(t, err)
assert.Equal(t, uint64(0), seq)
seq = rapid.Uint64().Draw(t, "seq").(uint64)
seq = rapid.Uint64().Draw(t, "seq")
v := cdc.EncodeValue(seq)
seq2, err := cdc.DecodeValue(v)
+3 -3
View File
@@ -17,8 +17,8 @@ import (
func TestUniqueKeyCodec(t *testing.T) {
rapid.Check(t, func(t *rapid.T) {
keyCodec := testutil.TestKeyCodecGen(1, 5).Draw(t, "keyCodec").(testutil.TestKeyCodec)
pkCodec := testutil.TestKeyCodecGen(1, 5).Draw(t, "primaryKeyCodec").(testutil.TestKeyCodec)
keyCodec := testutil.TestKeyCodecGen(1, 5).Draw(t, "keyCodec")
pkCodec := testutil.TestKeyCodecGen(1, 5).Draw(t, "primaryKeyCodec")
// check if we have a trivial unique index where all of the fields
// in the primary key are in the unique key, we should expect an
@@ -51,7 +51,7 @@ func TestUniqueKeyCodec(t *testing.T) {
}
for i := 0; i < 100; i++ {
a := testutil.GenA.Draw(t, fmt.Sprintf("a%d", i)).(*testpb.ExampleTable)
a := testutil.GenA.Draw(t, fmt.Sprintf("a%d", i))
key := keyCodec.Codec.GetKeyValues(a.ProtoReflect())
pk := pkCodec.Codec.GetKeyValues(a.ProtoReflect())
uniq1 := &ormkv.IndexKeyEntry{
+1 -1
View File
@@ -15,7 +15,7 @@ require (
google.golang.org/grpc v1.49.0
google.golang.org/protobuf v1.28.1
gotest.tools/v3 v3.3.0
pgregory.net/rapid v0.5.1
pgregory.net/rapid v0.5.2
)
require (
+2
View File
@@ -259,3 +259,5 @@ gotest.tools/v3 v3.3.0/go.mod h1:Mcr9QNxkg0uMvy/YElmo4SpXgJKWgQvYrT7Kw5RzJ1A=
pgregory.net/rapid v0.4.7/go.mod h1:UYpPVyjFHzYBGHIxLFoupi8vwk6rXNzRY9OMvVxFIOU=
pgregory.net/rapid v0.5.1 h1:U7LVKOJavGH81G5buGiyztKCmpQLfepzitHEKDLQ8ug=
pgregory.net/rapid v0.5.1/go.mod h1:PY5XlDGj0+V1FCq0o192FdRhpKHGTRIWBgqjDBTrq04=
pgregory.net/rapid v0.5.2 h1:zC+jmuzcz5yJvG/igG06aLx8kcGmZY435NcuyhblKjY=
pgregory.net/rapid v0.5.2/go.mod h1:PY5XlDGj0+V1FCq0o192FdRhpKHGTRIWBgqjDBTrq04=
+28 -27
View File
@@ -18,92 +18,92 @@ import (
// TestFieldSpec defines a test field against the testpb.ExampleTable message.
type TestFieldSpec struct {
FieldName protoreflect.Name
Gen *rapid.Generator
Gen *rapid.Generator[any]
}
var TestFieldSpecs = []TestFieldSpec{
{
"u32",
rapid.Uint32(),
rapid.Uint32().AsAny(),
},
{
"u64",
rapid.Uint64(),
rapid.Uint64().AsAny(),
},
{
"str",
rapid.String().Filter(func(x string) bool {
// filter out null terminators
return strings.IndexByte(x, 0) < 0
}),
}).AsAny(),
},
{
"bz",
rapid.SliceOfN(rapid.Byte(), 0, math.MaxUint32),
rapid.SliceOfN(rapid.Byte(), 0, math.MaxUint32).AsAny(),
},
{
"i32",
rapid.Int32(),
rapid.Int32().AsAny(),
},
{
"f32",
rapid.Uint32(),
rapid.Uint32().AsAny(),
},
{
"s32",
rapid.Int32(),
rapid.Int32().AsAny(),
},
{
"sf32",
rapid.Int32(),
rapid.Int32().AsAny(),
},
{
"i64",
rapid.Int64(),
rapid.Int64().AsAny(),
},
{
"f64",
rapid.Uint64(),
rapid.Uint64().AsAny(),
},
{
"s64",
rapid.Int64(),
rapid.Int64().AsAny(),
},
{
"sf64",
rapid.Int64(),
rapid.Int64().AsAny(),
},
{
"b",
rapid.Bool(),
rapid.Bool().AsAny(),
},
{
"ts",
rapid.Custom(func(t *rapid.T) protoreflect.Message {
seconds := rapid.Int64Range(-9999999999, 9999999999).Draw(t, "seconds").(int64)
nanos := rapid.Int32Range(0, 999999999).Draw(t, "nanos").(int32)
seconds := rapid.Int64Range(-9999999999, 9999999999).Draw(t, "seconds")
nanos := rapid.Int32Range(0, 999999999).Draw(t, "nanos")
return (&timestamppb.Timestamp{
Seconds: seconds,
Nanos: nanos,
}).ProtoReflect()
}),
}).AsAny(),
},
{
"dur",
rapid.Custom(func(t *rapid.T) protoreflect.Message {
seconds := rapid.Int64Range(0, 315576000000).Draw(t, "seconds").(int64)
nanos := rapid.Int32Range(0, 999999999).Draw(t, "nanos").(int32)
seconds := rapid.Int64Range(0, 315576000000).Draw(t, "seconds")
nanos := rapid.Int32Range(0, 999999999).Draw(t, "nanos")
return (&durationpb.Duration{
Seconds: seconds,
Nanos: nanos,
}).ProtoReflect()
}),
}).AsAny(),
},
{
"e",
rapid.Int32().Map(func(x int32) protoreflect.EnumNumber {
rapid.Transform(rapid.Int32(), func(x int32) protoreflect.EnumNumber {
return protoreflect.EnumNumber(x)
}),
}).AsAny(),
},
}
@@ -125,10 +125,10 @@ type TestKeyCodec struct {
Codec *ormkv.KeyCodec
}
func TestFieldSpecsGen(minLen, maxLen int) *rapid.Generator {
func TestFieldSpecsGen(minLen, maxLen int) *rapid.Generator[[]TestFieldSpec] {
return rapid.Custom(func(t *rapid.T) []TestFieldSpec {
xs := rapid.SliceOfNDistinct(rapid.IntRange(0, len(TestFieldSpecs)-1), minLen, maxLen, func(i int) int { return i }).
Draw(t, "fieldSpecIndexes").([]int)
Draw(t, "fieldSpecIndexes")
var specs []TestFieldSpec
@@ -141,16 +141,16 @@ func TestFieldSpecsGen(minLen, maxLen int) *rapid.Generator {
})
}
func TestKeyCodecGen(minLen, maxLen int) *rapid.Generator {
func TestKeyCodecGen(minLen, maxLen int) *rapid.Generator[TestKeyCodec] {
return rapid.Custom(func(t *rapid.T) TestKeyCodec {
specs := TestFieldSpecsGen(minLen, maxLen).Draw(t, "fieldSpecs").([]TestFieldSpec)
specs := TestFieldSpecsGen(minLen, maxLen).Draw(t, "fieldSpecs")
var fields []protoreflect.Name
for _, spec := range specs {
fields = append(fields, spec.FieldName)
}
prefix := rapid.SliceOfN(rapid.Byte(), 0, 5).Draw(t, "prefix").([]byte)
prefix := rapid.SliceOfN(rapid.Byte(), 0, 5).Draw(t, "prefix")
msgType := (&testpb.ExampleTable{}).ProtoReflect().Type()
cdc, err := ormkv.NewKeyCodec(prefix, msgType, fields)
@@ -169,6 +169,7 @@ func (k TestKeyCodec) Draw(t *rapid.T, id string) []protoreflect.Value {
n := len(k.KeySpecs)
keyValues := make([]protoreflect.Value, n)
for i, k := range k.KeySpecs {
keyValues[i] = protoreflect.ValueOf(k.Gen.Draw(t, fmt.Sprintf("%s[%d]", id, i)))
}
return keyValues
+8 -8
View File
@@ -500,7 +500,7 @@ func runTestScenario(t *testing.T, table ormtable.Table, backend ormtable.Backen
}
func TestRandomTableData(t *testing.T) {
testTable(t, TableDataGen(testutil.GenA, 100).Example().(*TableData))
testTable(t, TableDataGen(testutil.GenA, 100).Example())
}
func testTable(t *testing.T, tableData *TableData) {
@@ -553,8 +553,8 @@ func testIndex(t *testing.T, model *IndexModel) {
checkIteratorAgainstSlice(t, it, reverseData(model.data))
rapid.Check(t, func(t *rapid.T) {
i := rapid.IntRange(0, len(model.data)-2).Draw(t, "i").(int)
j := rapid.IntRange(i+1, len(model.data)-1).Draw(t, "j").(int)
i := rapid.IntRange(0, len(model.data)-2).Draw(t, "i")
j := rapid.IntRange(i+1, len(model.data)-1).Draw(t, "j")
start, _, err := model.index.(ormkv.IndexCodec).EncodeKeyFromMessage(model.data[i].ProtoReflect())
assert.NilError(t, err)
@@ -630,10 +630,10 @@ func checkIteratorAgainstSlice(t assert.TestingT, iterator ormtable.Iterator, da
}
}
func TableDataGen(elemGen *rapid.Generator, n int) *rapid.Generator {
func TableDataGen[T proto.Message](elemGen *rapid.Generator[T], n int) *rapid.Generator[*TableData] {
return rapid.Custom(func(t *rapid.T) *TableData {
prefix := rapid.SliceOfN(rapid.Byte(), 0, 5).Draw(t, "prefix").([]byte)
message := elemGen.Draw(t, "message").(proto.Message)
prefix := rapid.SliceOfN(rapid.Byte(), 0, 5).Draw(t, "prefix")
message := elemGen.Draw(t, "message")
table, err := ormtable.Build(ormtable.Options{
Prefix: prefix,
MessageType: message.ProtoReflect().Type(),
@@ -646,7 +646,7 @@ func TableDataGen(elemGen *rapid.Generator, n int) *rapid.Generator {
store := ormtable.WrapContextDefault(testkv.NewSplitMemBackend())
for i := 0; i < n; {
message = elemGen.Draw(t, fmt.Sprintf("message[%d]", i)).(proto.Message)
message = elemGen.Draw(t, fmt.Sprintf("message[%d]", i))
err := table.Insert(store, message)
if sdkerrors.IsOf(err, ormerrors.PrimaryKeyConstraintViolation, ormerrors.UniqueKeyViolation) {
continue
@@ -723,7 +723,7 @@ func TestJSONExportImport(t *testing.T) {
store := ormtable.WrapContextDefault(testkv.NewSplitMemBackend())
for i := 0; i < 100; {
x := testutil.GenA.Example().(proto.Message)
x := testutil.GenA.Example()
err = table.Insert(store, x)
if sdkerrors.IsOf(err, ormerrors.PrimaryKeyConstraintViolation, ormerrors.UniqueKeyViolation) {
continue