From e6931570c3b98ec2f354b73e0cdd7bc68f07c6a2 Mon Sep 17 00:00:00 2001 From: SoXX Date: Wed, 19 Jun 2024 22:16:42 +0000 Subject: [PATCH] chore(postgres): removed dead code --- test/tag_test.go | 104 ----------------------------------------------- 1 file changed, 104 deletions(-) delete mode 100644 test/tag_test.go diff --git a/test/tag_test.go b/test/tag_test.go deleted file mode 100644 index 3c9c4f8..0000000 --- a/test/tag_test.go +++ /dev/null @@ -1,104 +0,0 @@ -package test - -import ( - "context" - "git.dragse.it/anthrove/otter-space-sdk/pkg/database" - "git.dragse.it/anthrove/otter-space-sdk/pkg/models" - "git.dragse.it/anthrove/otter-space-sdk/pkg/models/graphModels" - "log" - "strconv" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/suite" -) - -type CustomerRepoTestSuite struct { - suite.Suite - database database.OtterSpace - pgContainer *PostgresContainer - ctx context.Context -} - -func (suite *CustomerRepoTestSuite) SetupSuite() { - suite.ctx = context.Background() - pgContainer, err := CreatePostgresContainer(suite.ctx) - if err != nil { - log.Fatal(err) - } - suite.pgContainer = pgContainer - - databaseClient := database.NewPostgresqlConnection(true) - containerInspect, _ := suite.pgContainer.Inspect(suite.ctx) - dbPortMap := containerInspect.NetworkSettings.Ports - var dbPortStr string - for _, v := range dbPortMap { - for _, n := range v { - dbPortStr = n.HostPort - } - } - dbPort, err := strconv.Atoi(dbPortStr) - if err != nil { - log.Fatal(err) - } - err = databaseClient.Connect(suite.ctx, "localhost", suite.pgContainer.DatabaseUser, suite.pgContainer.DatabasePassword, suite.pgContainer.DatabaseName, dbPort, "disable", "Europe/Berlin") - if err != nil { - log.Fatal(err) - } - suite.database = databaseClient - -} - -func (suite *CustomerRepoTestSuite) TearDownSuite() { - if err := suite.pgContainer.Terminate(suite.ctx); err != nil { - log.Fatalf("error terminating postgres container: %s", err) - } -} - -func (suite *CustomerRepoTestSuite) TestCreateTagNodeWitRelation() { - t := suite.T() - post := graphModels.AnthrovePost{ - PostID: "1234", - Rating: models.SFW, - } - - tag := &graphModels.AnthroveTag{ - Name: "test_tag", - Type: "general", - } - - err := suite.database.AddPost(suite.ctx, &post) - - if err != nil { - t.Fatal(err) - } - - err = suite.database.AddTagWithRelationToPost(suite.ctx, "1234", tag) - - assert.NoError(t, err) -} - -func (suite *CustomerRepoTestSuite) TestGetTags() { - t := suite.T() - - expectedTag := []graphModels.TagsWithFrequency{ - { - Frequency: 0, - Tags: graphModels.AnthroveTag{ - Name: "test_tag", - Type: "general", - }, - }, - } - - tag, err := suite.database.GetAllTags(suite.ctx) - - assert.NoError(t, err) - assert.Equal(t, expectedTag, tag) - assert.Len(t, tag, 1) - -} - -func TestCustomerRepoTestSuite(t *testing.T) { - suite.Run(t, new(CustomerRepoTestSuite)) -}