Skip to content

Commit

Permalink
test(documents): update tests for latest api
Browse files Browse the repository at this point in the history
Signed-off-by: Marco Sanchotene <[email protected]>
  • Loading branch information
marcosanchotene authored and jeroiraz committed Oct 23, 2023
1 parent 56f113b commit 7ea064d
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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().
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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() {
Expand Down Expand Up @@ -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",
}
Expand All @@ -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": "",
}
Expand All @@ -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).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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).
Expand Down

0 comments on commit 7ea064d

Please sign in to comment.