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:
co-authored by
Amaury M
Aaron Craelius
Julien Robert
parent
d07b28d2bf
commit
084e129fcf
@@ -87,8 +87,8 @@ func TestDec(t *testing.T) {
|
||||
require.True(t, minusOne.IsNegative())
|
||||
}
|
||||
|
||||
var genDec *rapid.Generator = rapid.Custom(func(t *rapid.T) Dec {
|
||||
f := rapid.Float64().Draw(t, "f").(float64)
|
||||
var genDec *rapid.Generator[Dec] = rapid.Custom(func(t *rapid.T) Dec {
|
||||
f := rapid.Float64().Draw(t, "f")
|
||||
dec, err := NewDecFromString(fmt.Sprintf("%g", f))
|
||||
require.NoError(t, err)
|
||||
return dec
|
||||
@@ -101,8 +101,8 @@ type floatAndDec struct {
|
||||
}
|
||||
|
||||
// Generate a Dec value along with the float used to create it
|
||||
var genFloatAndDec *rapid.Generator = rapid.Custom(func(t *rapid.T) floatAndDec {
|
||||
f := rapid.Float64().Draw(t, "f").(float64)
|
||||
var genFloatAndDec *rapid.Generator[floatAndDec] = rapid.Custom(func(t *rapid.T) floatAndDec {
|
||||
f := rapid.Float64().Draw(t, "f")
|
||||
dec, err := NewDecFromString(fmt.Sprintf("%g", f))
|
||||
require.NoError(t, err)
|
||||
return floatAndDec{f, dec}
|
||||
@@ -110,7 +110,7 @@ var genFloatAndDec *rapid.Generator = rapid.Custom(func(t *rapid.T) floatAndDec
|
||||
|
||||
// Property: n == NewDecFromInt64(n).Int64()
|
||||
func testDecInt64(t *rapid.T) {
|
||||
nIn := rapid.Int64().Draw(t, "n").(int64)
|
||||
nIn := rapid.Int64().Draw(t, "n")
|
||||
nOut, err := NewDecFromInt64(nIn).Int64()
|
||||
|
||||
require.NoError(t, err)
|
||||
@@ -119,7 +119,7 @@ func testDecInt64(t *rapid.T) {
|
||||
|
||||
// Property: 0 + a == a
|
||||
func testAddLeftIdentity(t *rapid.T) {
|
||||
a := genDec.Draw(t, "a").(Dec)
|
||||
a := genDec.Draw(t, "a")
|
||||
zero := NewDecFromInt64(0)
|
||||
|
||||
b, err := zero.Add(a)
|
||||
@@ -130,7 +130,7 @@ func testAddLeftIdentity(t *rapid.T) {
|
||||
|
||||
// Property: a + 0 == a
|
||||
func testAddRightIdentity(t *rapid.T) {
|
||||
a := genDec.Draw(t, "a").(Dec)
|
||||
a := genDec.Draw(t, "a")
|
||||
zero := NewDecFromInt64(0)
|
||||
|
||||
b, err := a.Add(zero)
|
||||
@@ -141,8 +141,8 @@ func testAddRightIdentity(t *rapid.T) {
|
||||
|
||||
// Property: a + b == b + a
|
||||
func testAddCommutative(t *rapid.T) {
|
||||
a := genDec.Draw(t, "a").(Dec)
|
||||
b := genDec.Draw(t, "b").(Dec)
|
||||
a := genDec.Draw(t, "a")
|
||||
b := genDec.Draw(t, "b")
|
||||
|
||||
c, err := a.Add(b)
|
||||
require.NoError(t, err)
|
||||
@@ -155,9 +155,9 @@ func testAddCommutative(t *rapid.T) {
|
||||
|
||||
// Property: (a + b) + c == a + (b + c)
|
||||
func testAddAssociative(t *rapid.T) {
|
||||
a := genDec.Draw(t, "a").(Dec)
|
||||
b := genDec.Draw(t, "b").(Dec)
|
||||
c := genDec.Draw(t, "c").(Dec)
|
||||
a := genDec.Draw(t, "a")
|
||||
b := genDec.Draw(t, "b")
|
||||
c := genDec.Draw(t, "c")
|
||||
|
||||
// (a + b) + c
|
||||
d, err := a.Add(b)
|
||||
@@ -178,7 +178,7 @@ func testAddAssociative(t *rapid.T) {
|
||||
|
||||
// Property: a - 0 == a
|
||||
func testSubRightIdentity(t *rapid.T) {
|
||||
a := genDec.Draw(t, "a").(Dec)
|
||||
a := genDec.Draw(t, "a")
|
||||
zero := NewDecFromInt64(0)
|
||||
|
||||
b, err := a.Sub(zero)
|
||||
@@ -189,7 +189,7 @@ func testSubRightIdentity(t *rapid.T) {
|
||||
|
||||
// Property: a - a == 0
|
||||
func testSubZero(t *rapid.T) {
|
||||
a := genDec.Draw(t, "a").(Dec)
|
||||
a := genDec.Draw(t, "a")
|
||||
zero := NewDecFromInt64(0)
|
||||
|
||||
b, err := a.Sub(a)
|
||||
@@ -200,8 +200,8 @@ func testSubZero(t *rapid.T) {
|
||||
|
||||
// Property: (a - b) + b == a
|
||||
func testSubAdd(t *rapid.T) {
|
||||
a := genDec.Draw(t, "a").(Dec)
|
||||
b := genDec.Draw(t, "b").(Dec)
|
||||
a := genDec.Draw(t, "a")
|
||||
b := genDec.Draw(t, "b")
|
||||
|
||||
c, err := a.Sub(b)
|
||||
require.NoError(t, err)
|
||||
@@ -214,8 +214,8 @@ func testSubAdd(t *rapid.T) {
|
||||
|
||||
// Property: (a + b) - b == a
|
||||
func testAddSub(t *rapid.T) {
|
||||
a := genDec.Draw(t, "a").(Dec)
|
||||
b := genDec.Draw(t, "b").(Dec)
|
||||
a := genDec.Draw(t, "a")
|
||||
b := genDec.Draw(t, "b")
|
||||
|
||||
c, err := a.Add(b)
|
||||
require.NoError(t, err)
|
||||
@@ -228,23 +228,23 @@ func testAddSub(t *rapid.T) {
|
||||
|
||||
// Property: Cmp(a, b) == -Cmp(b, a)
|
||||
func testCmpInverse(t *rapid.T) {
|
||||
a := genDec.Draw(t, "a").(Dec)
|
||||
b := genDec.Draw(t, "b").(Dec)
|
||||
a := genDec.Draw(t, "a")
|
||||
b := genDec.Draw(t, "b")
|
||||
|
||||
require.Equal(t, a.Cmp(b), -b.Cmp(a))
|
||||
}
|
||||
|
||||
// Property: IsEqual(a, b) == IsEqual(b, a)
|
||||
func testEqualCommutative(t *rapid.T) {
|
||||
a := genDec.Draw(t, "a").(Dec)
|
||||
b := genDec.Draw(t, "b").(Dec)
|
||||
a := genDec.Draw(t, "a")
|
||||
b := genDec.Draw(t, "b")
|
||||
|
||||
require.Equal(t, a.IsEqual(b), b.IsEqual(a))
|
||||
}
|
||||
|
||||
// Property: isNegative(f) == isNegative(NewDecFromString(f.String()))
|
||||
func testIsNegative(t *rapid.T) {
|
||||
floatAndDec := genFloatAndDec.Draw(t, "floatAndDec").(floatAndDec)
|
||||
floatAndDec := genFloatAndDec.Draw(t, "floatAndDec")
|
||||
f, dec := floatAndDec.float, floatAndDec.dec
|
||||
|
||||
require.Equal(t, f < 0, dec.IsNegative())
|
||||
|
||||
@@ -10,9 +10,9 @@ import (
|
||||
// generate empty strings for Name.
|
||||
var genTableModel = rapid.Custom(func(t *rapid.T) *testdata.TableModel {
|
||||
return &testdata.TableModel{
|
||||
Id: rapid.Uint64().Draw(t, "id").(uint64),
|
||||
Name: rapid.StringN(1, 100, 150).Draw(t, "name").(string),
|
||||
Number: rapid.Uint64().Draw(t, "number ").(uint64),
|
||||
Metadata: []byte(rapid.StringN(1, 100, 150).Draw(t, "metadata").(string)),
|
||||
Id: rapid.Uint64().Draw(t, "id"),
|
||||
Name: rapid.StringN(1, 100, 150).Draw(t, "name"),
|
||||
Number: rapid.Uint64().Draw(t, "number "),
|
||||
Metadata: []byte(rapid.StringN(1, 100, 150).Draw(t, "metadata")),
|
||||
}
|
||||
})
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
|
||||
func TestPrefixRangeProperty(t *testing.T) {
|
||||
t.Run("TestPrefixRange", rapid.MakeCheck(func(t *rapid.T) {
|
||||
prefix := rapid.SliceOf(rapid.Byte()).Draw(t, "prefix").([]byte)
|
||||
prefix := rapid.SliceOf(rapid.Byte()).Draw(t, "prefix")
|
||||
|
||||
start, end := PrefixRange(prefix)
|
||||
|
||||
|
||||
@@ -15,14 +15,14 @@ import (
|
||||
func TestPaginationProperty(t *testing.T) {
|
||||
t.Run("TestPagination", rapid.MakeCheck(func(t *rapid.T) {
|
||||
// Create a slice of group members
|
||||
tableModels := rapid.SliceOf(genTableModel).Draw(t, "tableModels").([]*testdata.TableModel)
|
||||
tableModels := rapid.SliceOf(genTableModel).Draw(t, "tableModels")
|
||||
|
||||
// Choose a random limit for paging
|
||||
upperLimit := uint64(len(tableModels))
|
||||
if upperLimit == 0 {
|
||||
upperLimit = 1
|
||||
}
|
||||
limit := rapid.Uint64Range(1, upperLimit).Draw(t, "limit").(uint64)
|
||||
limit := rapid.Uint64Range(1, upperLimit).Draw(t, "limit")
|
||||
|
||||
// Reconstruct the slice from offset pages
|
||||
reconstructedTableModels := make([]*testdata.TableModel, 0, len(tableModels))
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
)
|
||||
|
||||
func TestPrimaryKeyTable(t *testing.T) {
|
||||
rapid.Check(t, rapid.Run(&primaryKeyMachine{}))
|
||||
rapid.Check(t, rapid.Run[*primaryKeyMachine]())
|
||||
}
|
||||
|
||||
// primaryKeyMachine is a state machine model of the PrimaryKeyTable. The state
|
||||
@@ -39,9 +39,9 @@ func (m *primaryKeyMachine) stateKeys() []string {
|
||||
|
||||
// Generate a TableModel that has a 50% chance of being a part of the existing
|
||||
// state
|
||||
func (m *primaryKeyMachine) genTableModel() *rapid.Generator {
|
||||
func (m *primaryKeyMachine) genTableModel() *rapid.Generator[*testdata.TableModel] {
|
||||
genStateTableModel := rapid.Custom(func(t *rapid.T) *testdata.TableModel {
|
||||
pk := rapid.SampledFrom(m.stateKeys()).Draw(t, "key").(string)
|
||||
pk := rapid.SampledFrom(m.stateKeys()).Draw(t, "key")
|
||||
return m.state[pk]
|
||||
})
|
||||
|
||||
@@ -86,7 +86,7 @@ func (m *primaryKeyMachine) Check(t *rapid.T) {
|
||||
// Create is one of the model commands. It adds an object to the table, creating
|
||||
// an error if it already exists.
|
||||
func (m *primaryKeyMachine) Create(t *rapid.T) {
|
||||
g := genTableModel.Draw(t, "g").(*testdata.TableModel)
|
||||
g := genTableModel.Draw(t, "g")
|
||||
pk := string(PrimaryKey(g))
|
||||
|
||||
t.Logf("pk: %v", pk)
|
||||
@@ -105,9 +105,9 @@ func (m *primaryKeyMachine) Create(t *rapid.T) {
|
||||
// Update is one of the model commands. It updates the value at a given primary
|
||||
// key and fails if that primary key doesn't already exist in the table.
|
||||
func (m *primaryKeyMachine) Update(t *rapid.T) {
|
||||
tm := m.genTableModel().Draw(t, "tm").(*testdata.TableModel)
|
||||
tm := m.genTableModel().Draw(t, "tm")
|
||||
|
||||
newName := rapid.StringN(1, 100, 150).Draw(t, "newName").(string)
|
||||
newName := rapid.StringN(1, 100, 150).Draw(t, "newName")
|
||||
tm.Name = newName
|
||||
|
||||
// Perform the real Update
|
||||
@@ -128,7 +128,7 @@ func (m *primaryKeyMachine) Update(t *rapid.T) {
|
||||
// Set is one of the model commands. It sets the value at a key in the table
|
||||
// whether it exists or not.
|
||||
func (m *primaryKeyMachine) Set(t *rapid.T) {
|
||||
g := genTableModel.Draw(t, "g").(*testdata.TableModel)
|
||||
g := genTableModel.Draw(t, "g")
|
||||
pk := string(PrimaryKey(g))
|
||||
|
||||
err := m.table.Set(m.store, g)
|
||||
@@ -141,7 +141,7 @@ func (m *primaryKeyMachine) Set(t *rapid.T) {
|
||||
// primary key from the table and returns an error if that primary key doesn't
|
||||
// already exist in the table.
|
||||
func (m *primaryKeyMachine) Delete(t *rapid.T) {
|
||||
tm := m.genTableModel().Draw(t, "tm").(*testdata.TableModel)
|
||||
tm := m.genTableModel().Draw(t, "tm")
|
||||
|
||||
// Perform the real Delete
|
||||
err := m.table.Delete(m.store, tm)
|
||||
@@ -161,7 +161,7 @@ func (m *primaryKeyMachine) Delete(t *rapid.T) {
|
||||
// Has is one of the model commands. It checks whether a key already exists in
|
||||
// the table.
|
||||
func (m *primaryKeyMachine) Has(t *rapid.T) {
|
||||
pk := PrimaryKey(m.genTableModel().Draw(t, "g").(*testdata.TableModel))
|
||||
pk := PrimaryKey(m.genTableModel().Draw(t, "g"))
|
||||
|
||||
realHas := m.table.Has(m.store, pk)
|
||||
modelHas := m.state[string(pk)] != nil
|
||||
@@ -172,7 +172,7 @@ func (m *primaryKeyMachine) Has(t *rapid.T) {
|
||||
// GetOne is one of the model commands. It fetches an object from the table by
|
||||
// its primary key and returns an error if that primary key isn't in the table.
|
||||
func (m *primaryKeyMachine) GetOne(t *rapid.T) {
|
||||
pk := PrimaryKey(m.genTableModel().Draw(t, "tm").(*testdata.TableModel))
|
||||
pk := PrimaryKey(m.genTableModel().Draw(t, "tm"))
|
||||
|
||||
var tm testdata.TableModel
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
)
|
||||
|
||||
func TestSequence(t *testing.T) {
|
||||
rapid.Check(t, rapid.Run(&sequenceMachine{}))
|
||||
rapid.Check(t, rapid.Run[*sequenceMachine]())
|
||||
}
|
||||
|
||||
// sequenceMachine is a state machine model of Sequence. It simply uses a uint64
|
||||
@@ -32,7 +32,7 @@ func (m *sequenceMachine) Init(t *rapid.T) {
|
||||
m.seq = &seq
|
||||
|
||||
// Choose initial sequence value
|
||||
initSeqVal := rapid.Uint64().Draw(t, "initSeqVal").(uint64)
|
||||
initSeqVal := rapid.Uint64().Draw(t, "initSeqVal")
|
||||
err := m.seq.InitVal(m.store, initSeqVal)
|
||||
require.NoError(t, err)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user