From f43fdd9939e4db314f407672f445042ec123cf59 Mon Sep 17 00:00:00 2001 From: Andrew Sisley Date: Mon, 2 Oct 2023 14:41:50 -0400 Subject: [PATCH] Decouple P2P unit tests from private function 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. --- db/p2p_collection_test.go | 38 +++++++++++++------------------------- 1 file changed, 13 insertions(+), 25 deletions(-) diff --git a/db/p2p_collection_test.go b/db/p2p_collection_test.go index db6b1e6417..61feb3ea76 100644 --- a/db/p2p_collection_test.go +++ b/db/p2p_collection_test.go @@ -12,6 +12,7 @@ package db import ( "context" + "fmt" "testing" "github.com/stretchr/testify/require" @@ -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