Skip to content

Commit

Permalink
Decouple P2P unit tests from private function
Browse files Browse the repository at this point in the history
The private funtion is not the one under test, and so we should not be forced to change the P2P tests every time we wish to change this private function. May be a historical artifact.
  • Loading branch information
AndrewSisley committed Oct 2, 2023
1 parent 6aef3e7 commit bc1052c
Showing 1 changed file with 13 additions and 25 deletions.
38 changes: 13 additions & 25 deletions db/p2p_collection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ package db

import (
"context"
"fmt"
"testing"

"github.com/stretchr/testify/require"
Expand All @@ -25,31 +26,18 @@ func newTestCollection(
db *implicitTxnDB,
name string,
) client.Collection {
desc := client.CollectionDescription{
Name: name,
Schema: client.SchemaDescription{
Name: name,
Fields: []client.FieldDescription{
{
Name: "_key",
Kind: client.FieldKind_DocKey,
},
{
Name: "Name",
Kind: client.FieldKind_STRING,
Typ: client.LWW_REGISTER,
},
},
},
}

txn, err := db.db.NewTxn(ctx, false)
require.NoError(t, err)

col, err := db.db.createCollection(ctx, txn, desc)
require.NoError(t, err)

err = txn.Commit(ctx)
_, err := db.AddSchema(
ctx,
fmt.Sprintf(
`type %s {
Name: String
}`,
name,
),
)
require.NoError(t, err)

col, err := db.GetCollectionByName(ctx, name)
require.NoError(t, err)

return col
Expand Down

0 comments on commit bc1052c

Please sign in to comment.