Skip to content

Commit

Permalink
Update naming in repo test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
sudiptob2 committed Nov 26, 2024
1 parent eac17a5 commit 4bf9699
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 42 deletions.
10 changes: 5 additions & 5 deletions internal/database/repository/application_int_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ import (
"github.com/G-Research/unicorn-history-server/internal/util"
)

type ApplicationTestSuite struct {
type ApplicationIntTest struct {
suite.Suite
pool *pgxpool.Pool
repo *PostgresRepository
}

func (as *ApplicationTestSuite) SetupSuite() {
func (as *ApplicationIntTest) SetupSuite() {
ctx := context.Background()
require.NotNil(as.T(), as.pool)
repo, err := NewPostgresRepository(as.pool)
Expand All @@ -32,11 +32,11 @@ func (as *ApplicationTestSuite) SetupSuite() {
seedApplications(ctx, as.T(), as.repo)
}

func (as *ApplicationTestSuite) TearDownSuite() {
func (as *ApplicationIntTest) TearDownSuite() {
as.pool.Close()
}

func (as *ApplicationTestSuite) TestGetAllApplications() {
func (as *ApplicationIntTest) TestGetAllApplications() {
ctx := context.Background()
tests := []struct {
name string
Expand Down Expand Up @@ -106,7 +106,7 @@ func (as *ApplicationTestSuite) TestGetAllApplications() {
}
}

func (as *ApplicationTestSuite) TestGetAppsPerPartitionPerQueue() {
func (as *ApplicationIntTest) TestGetAppsPerPartitionPerQueue() {
ctx := context.Background()
tests := []struct {
name string
Expand Down
10 changes: 5 additions & 5 deletions internal/database/repository/history_int_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ import (
"github.com/G-Research/unicorn-history-server/internal/util"
)

type HistoryTestSuite struct {
type HistoryIntTest struct {
suite.Suite
pool *pgxpool.Pool
repo *PostgresRepository
}

func (hs *HistoryTestSuite) SetupSuite() {
func (hs *HistoryIntTest) SetupSuite() {
ctx := context.Background()
require.NotNil(hs.T(), hs.pool)
repo, err := NewPostgresRepository(hs.pool)
Expand All @@ -31,11 +31,11 @@ func (hs *HistoryTestSuite) SetupSuite() {
seedHistory(ctx, hs.T(), hs.repo)
}

func (hs *HistoryTestSuite) TearDownSuite() {
func (hs *HistoryIntTest) TearDownSuite() {
hs.pool.Close()
}

func (hs *HistoryTestSuite) TestGetApplicationsHistory() {
func (hs *HistoryIntTest) TestGetApplicationsHistory() {
ctx := context.Background()
tests := []struct {
name string
Expand Down Expand Up @@ -76,7 +76,7 @@ func (hs *HistoryTestSuite) TestGetApplicationsHistory() {
}
}

func (hs *HistoryTestSuite) TestGetContainersHistory() {
func (hs *HistoryIntTest) TestGetContainersHistory() {
ctx := context.Background()
tests := []struct {
name string
Expand Down
8 changes: 4 additions & 4 deletions internal/database/repository/node_int_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ import (
"github.com/G-Research/unicorn-history-server/internal/util"
)

type NodeTestSuite struct {
type NodeIntTest struct {
suite.Suite
pool *pgxpool.Pool
repo *PostgresRepository
}

var partitionID = ulid.Make().String()

func (ns *NodeTestSuite) SetupSuite() {
func (ns *NodeIntTest) SetupSuite() {
ctx := context.Background()
require.NotNil(ns.T(), ns.pool)
repo, err := NewPostgresRepository(ns.pool)
Expand All @@ -34,11 +34,11 @@ func (ns *NodeTestSuite) SetupSuite() {
seedNodes(ctx, ns.T(), ns.repo)
}

func (ns *NodeTestSuite) TearDownSuite() {
func (ns *NodeIntTest) TearDownSuite() {
ns.pool.Close()
}

func (ns *NodeTestSuite) TestGetNodesPerPartition() {
func (ns *NodeIntTest) TestGetNodesPerPartition() {
ctx := context.Background()
tests := []struct {
name string
Expand Down
8 changes: 4 additions & 4 deletions internal/database/repository/partitions_init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ import (
"github.com/G-Research/unicorn-history-server/internal/util"
)

type PartitionTestSuite struct {
type PartitionIntTest struct {
suite.Suite
pool *pgxpool.Pool
repo *PostgresRepository
}

func (ps *PartitionTestSuite) SetupSuite() {
func (ps *PartitionIntTest) SetupSuite() {
ctx := context.Background()
require.NotNil(ps.T(), ps.pool)
repo, err := NewPostgresRepository(ps.pool)
Expand All @@ -30,11 +30,11 @@ func (ps *PartitionTestSuite) SetupSuite() {
seedPartitions(ctx, ps.T(), ps.repo)
}

func (ps *PartitionTestSuite) TearDownSuite() {
func (ps *PartitionIntTest) TearDownSuite() {
ps.pool.Close()
}

func (ps *PartitionTestSuite) TestGetAllPartitions() {
func (ps *PartitionIntTest) TestGetAllPartitions() {
ctx := context.Background()
tests := []struct {
name string
Expand Down
16 changes: 8 additions & 8 deletions internal/database/repository/queue_int_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ import (
"github.com/stretchr/testify/suite"
)

type QueueTestSuite struct {
type QueueIntTest struct {
suite.Suite
pool *pgxpool.Pool
repo *PostgresRepository
}

func (qs *QueueTestSuite) SetupSuite() {
func (qs *QueueIntTest) SetupSuite() {
require.NotNil(qs.T(), qs.pool)
repo, err := NewPostgresRepository(qs.pool)
require.NoError(qs.T(), err)
Expand All @@ -28,11 +28,11 @@ func (qs *QueueTestSuite) SetupSuite() {
seedQueues(qs.T(), qs.repo)
}

func (qs *QueueTestSuite) TearDownSuite() {
func (qs *QueueIntTest) TearDownSuite() {
qs.pool.Close()
}

func (qs *QueueTestSuite) TestGetAllQueues() {
func (qs *QueueIntTest) TestGetAllQueues() {
ctx := context.Background()
tests := []struct {
name string
Expand All @@ -53,7 +53,7 @@ func (qs *QueueTestSuite) TestGetAllQueues() {
}
}

func (qs *QueueTestSuite) TestGetQueuesInPartition() {
func (qs *QueueIntTest) TestGetQueuesInPartition() {
ctx := context.Background()
tests := []struct {
name string
Expand Down Expand Up @@ -81,7 +81,7 @@ func (qs *QueueTestSuite) TestGetQueuesInPartition() {
}
}

func (qs *QueueTestSuite) TestGetQueue() {
func (qs *QueueIntTest) TestGetQueue() {
ctx := context.Background()
tests := []struct {
name string
Expand Down Expand Up @@ -119,7 +119,7 @@ func (qs *QueueTestSuite) TestGetQueue() {
}
}

func (qs *QueueTestSuite) TestDeleteQueues() {
func (qs *QueueIntTest) TestDeleteQueues() {
ctx := context.Background()
tests := []struct {
name string
Expand Down Expand Up @@ -163,7 +163,7 @@ func (qs *QueueTestSuite) TestDeleteQueues() {
}
}

func (qs *QueueTestSuite) TestUpdateQueue() {
func (qs *QueueIntTest) TestUpdateQueue() {
ctx := context.Background()
now := time.Now()
tests := []struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ import (
"github.com/G-Research/unicorn-history-server/test/database"
)

type RepositoryTestSuite struct {
type RepositorySuite struct {
suite.Suite
tp *database.TestPostgresContainer
pool *pgxpool.Pool
}

func (ts *RepositoryTestSuite) SetupSuite() {
func (ts *RepositorySuite) SetupSuite() {
ctx := context.Background()
cfg := database.InstanceConfig{
User: "test",
Expand All @@ -36,38 +36,38 @@ func (ts *RepositoryTestSuite) SetupSuite() {
ts.pool = tp.Pool(ctx, ts.T(), &cfg)
}

func (ts *RepositoryTestSuite) TearDownSuite() {
func (ts *RepositorySuite) TearDownSuite() {
err := ts.tp.Container.Terminate(context.Background())
require.NoError(ts.T(), err)
}

func (ts *RepositoryTestSuite) TestSubSuites() {
ts.T().Run("ApplicationTestSuite", func(t *testing.T) {
func (ts *RepositorySuite) TestSubSuites() {
ts.T().Run("ApplicationIntTest", func(t *testing.T) {
pool := database.CloneDB(t, ts.tp, ts.pool)
suite.Run(t, &ApplicationTestSuite{pool: pool})
suite.Run(t, &ApplicationIntTest{pool: pool})
})
ts.T().Run("HistoryTestSuite", func(t *testing.T) {
ts.T().Run("HistoryIntTest", func(t *testing.T) {
pool := database.CloneDB(t, ts.tp, ts.pool)
suite.Run(t, &HistoryTestSuite{pool: pool})
suite.Run(t, &HistoryIntTest{pool: pool})
})
ts.T().Run("NodeTestSuite", func(t *testing.T) {
ts.T().Run("NodeIntTest", func(t *testing.T) {
pool := database.CloneDB(t, ts.tp, ts.pool)
suite.Run(t, &NodeTestSuite{pool: pool})
suite.Run(t, &NodeIntTest{pool: pool})
})
ts.T().Run("QueueTestSuite", func(t *testing.T) {
ts.T().Run("QueueIntTest", func(t *testing.T) {
pool := database.CloneDB(t, ts.tp, ts.pool)
suite.Run(t, &QueueTestSuite{pool: pool})
suite.Run(t, &QueueIntTest{pool: pool})
})
ts.T().Run("PartitionTestSuite", func(t *testing.T) {
ts.T().Run("PartitionIntTest", func(t *testing.T) {
pool := database.CloneDB(t, ts.tp, ts.pool)
suite.Run(t, &PartitionTestSuite{pool: pool})
suite.Run(t, &PartitionIntTest{pool: pool})
})
}

func TestRepositoryIntegrationTestSuite(t *testing.T) {
func TestRepositoryIntegration(t *testing.T) {
if testing.Short() {
t.Skip("skipping integration test in short mode.")
}
topSuite := new(RepositoryTestSuite)
topSuite := new(RepositorySuite)
suite.Run(t, topSuite)
}

0 comments on commit 4bf9699

Please sign in to comment.