From 7f6beeb31b79b020aa87f04db15446b02046475a Mon Sep 17 00:00:00 2001 From: Marco Sanchotene Date: Thu, 19 Oct 2023 13:51:45 -0300 Subject: [PATCH] test(documents): update tests for latest api Signed-off-by: Marco Sanchotene --- .../documents_tests/actions/create_collections.go | 2 +- .../documents_tests/actions/session.go | 8 +++++++- .../documents_tests/create_collections_test.go | 13 ++++++------- .../documents_tests/create_indexes_test.go | 2 +- .../documents_tests/delete_collections_test.go | 4 ++-- 5 files changed, 17 insertions(+), 12 deletions(-) diff --git a/test/document_storage_tests/documents_tests/actions/create_collections.go b/test/document_storage_tests/documents_tests/actions/create_collections.go index d18bba98c5..d45524ed3a 100644 --- a/test/document_storage_tests/documents_tests/actions/create_collections.go +++ b/test/document_storage_tests/documents_tests/actions/create_collections.go @@ -154,7 +154,7 @@ func createCollection(expect *httpexpect.Expect, sessionID string, name string, WithHeader("grpc-metadata-sessionid", sessionID). WithJSON(payload). Expect(). - Status(http.StatusOK).JSON().Object().Empty() + Status(http.StatusOK).JSON().Object().IsEmpty() collection := expect.GET(fmt.Sprintf("/collection/%s", name)). WithHeader("grpc-metadata-sessionid", sessionID). diff --git a/test/document_storage_tests/documents_tests/actions/session.go b/test/document_storage_tests/documents_tests/actions/session.go index 383928b089..4535e0f993 100644 --- a/test/document_storage_tests/documents_tests/actions/session.go +++ b/test/document_storage_tests/documents_tests/actions/session.go @@ -34,7 +34,13 @@ func OpenSession(t *testing.T) (*httpexpect.Expect, string) { Database: "defaultdb", } - expect := httpexpect.Default(t, baseURL) + expect := httpexpect.WithConfig(httpexpect.Config{ + BaseURL: baseURL, + Reporter: httpexpect.NewAssertReporter(t), + Printers: []httpexpect.Printer{ + httpexpect.NewDebugPrinter(t, true), + }, + }) obj := expect.POST("/authorization/session/open"). WithJSON(user). Expect(). diff --git a/test/document_storage_tests/documents_tests/create_collections_test.go b/test/document_storage_tests/documents_tests/create_collections_test.go index 1ed37fe9a0..6fea1bb057 100644 --- a/test/document_storage_tests/documents_tests/create_collections_test.go +++ b/test/document_storage_tests/documents_tests/create_collections_test.go @@ -23,7 +23,6 @@ import ( "github.com/codenotary/immudb/test/document_storage_tests/documents_tests/actions" "github.com/gavv/httpexpect/v2" - "github.com/google/uuid" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/suite" ) @@ -37,7 +36,7 @@ type CreateCollectionsTestSuite struct { func (s *CreateCollectionsTestSuite) SetupTest() { s.expect, s.sessionID = actions.OpenSession(s.T()) - s.collection_name = uuid.New().String() + s.collection_name = "a" + uuid.New().String() } func (s *CreateCollectionsTestSuite) TestCreateCollectionWithName() { @@ -163,11 +162,11 @@ func (s *CreateCollectionsTestSuite) TestCreateCollectionWithEmptyBody() { WithHeader("grpc-metadata-sessionid", s.sessionID). WithJSON(payload). Expect(). - Status(http.StatusOK).JSON().Object().Empty() + Status(http.StatusOK).JSON().Object().IsEmpty() } func (s *CreateCollectionsTestSuite) TestCreateCollectionWithNameAndOneInvalidField() { - name := uuid.New().String() + name := "a" + uuid.New().String() payload := map[string]interface{}{ "fields": "birth_date", } @@ -186,7 +185,7 @@ func (s *CreateCollectionsTestSuite) TestCreateCollectionWithNameAndOneInvalidFi } func (s *CreateCollectionsTestSuite) TestCreateCollectionWithNameAndOneEmptyField() { - name := uuid.New().String() + name := "a" + uuid.New().String() payload := map[string]interface{}{ "fields": "", } @@ -205,12 +204,12 @@ func (s *CreateCollectionsTestSuite) TestCreateCollectionWithNameAndOneEmptyFiel } func (s *CreateCollectionsTestSuite) TestCreateCollectionWithExistingName() { - name := uuid.New().String() + name := "a" + uuid.New().String() s.expect.POST(fmt.Sprintf("/collection/%s", name)). WithHeader("grpc-metadata-sessionid", s.sessionID). Expect(). - Status(http.StatusOK).JSON().Object().Empty() + Status(http.StatusOK).JSON().Object().IsEmpty() s.expect.POST(fmt.Sprintf("/collection/%s", name)). WithHeader("grpc-metadata-sessionid", s.sessionID). diff --git a/test/document_storage_tests/documents_tests/create_indexes_test.go b/test/document_storage_tests/documents_tests/create_indexes_test.go index 9654db6581..9a8d866673 100644 --- a/test/document_storage_tests/documents_tests/create_indexes_test.go +++ b/test/document_storage_tests/documents_tests/create_indexes_test.go @@ -36,7 +36,7 @@ type IndexTestSuite struct { func (s *IndexTestSuite) SetupTest() { s.expect, s.sessionID = actions.OpenSession(s.T()) - s.collection_name = uuid.New().String() + s.collection_name = "a" + uuid.New().String() } func (s *IndexTestSuite) TestCreateIndexOnCollectionCreatedWithNameAndOneField() { diff --git a/test/document_storage_tests/documents_tests/delete_collections_test.go b/test/document_storage_tests/documents_tests/delete_collections_test.go index c64a4e94cd..46249cc78f 100644 --- a/test/document_storage_tests/documents_tests/delete_collections_test.go +++ b/test/document_storage_tests/documents_tests/delete_collections_test.go @@ -36,7 +36,7 @@ type DeleteCollectionsTestSuite struct { func (s *DeleteCollectionsTestSuite) SetupTest() { s.expect, s.token = actions.OpenSession(s.T()) - s.collection_name = uuid.New().String() + s.collection_name = "a" + uuid.New().String() } func (s *DeleteCollectionsTestSuite) TestDeleteCollectionCreatedWithName() { @@ -46,7 +46,7 @@ func (s *DeleteCollectionsTestSuite) TestDeleteCollectionCreatedWithName() { WithHeader("grpc-metadata-sessionid", s.token). Expect(). Status(http.StatusOK). - JSON().Object().Empty() + JSON().Object().IsEmpty() s.expect.GET(fmt.Sprintf("/collection/%s", s.collection_name)). WithHeader("grpc-metadata-sessionid", s.token).