Skip to content

Commit

Permalink
Remove unnecessary clear function from test database
Browse files Browse the repository at this point in the history
  • Loading branch information
tygern committed May 6, 2024
1 parent 2441632 commit 6f30b16
Show file tree
Hide file tree
Showing 8 changed files with 2 additions and 17 deletions.
1 change: 0 additions & 1 deletion internal/analyzer/analyze_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ func TestAnalyzer_Analyze(t *testing.T) {

testDb := testsupport.NewTestDb(t)
defer testDb.Close()
testDb.ClearTables()

embeddingsGateway := analyzer.NewEmbeddingsGateway(testDb.DB)
chunksGateway := collector.NewChunksGateway(testDb.DB)
Expand Down
3 changes: 0 additions & 3 deletions internal/analyzer/embeddings_gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
func TestEmbeddingsGateway_UnprocessedIds(t *testing.T) {
testDb := testsupport.NewTestDb(t)
defer testDb.Close()
testDb.ClearTables()

gateway := analyzer.NewEmbeddingsGateway(testDb.DB)

Expand All @@ -32,7 +31,6 @@ func TestEmbeddingsGateway_UnprocessedIds(t *testing.T) {
func TestEmbeddingsGateway_Save(t *testing.T) {
testDb := testsupport.NewTestDb(t)
defer testDb.Close()
testDb.ClearTables()

gateway := analyzer.NewEmbeddingsGateway(testDb.DB)

Expand All @@ -52,7 +50,6 @@ func TestEmbeddingsGateway_Save(t *testing.T) {
func TestEmbeddingsGateway_FindSimilar(t *testing.T) {
testDb := testsupport.NewTestDb(t)
defer testDb.Close()
testDb.ClearTables()

gateway := analyzer.NewEmbeddingsGateway(testDb.DB)

Expand Down
1 change: 0 additions & 1 deletion internal/app/index_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ func TestIndex_Post(t *testing.T) {

testDb := testsupport.NewTestDb(t)
defer testDb.Close()
testDb.ClearTables()

testDb.Execute("insert into data (id, source, content) values ('aaaaaaaa-2f3f-4bc9-8dba-ba397156cc16', 'https://example.com', 'some content')")
testDb.Execute("insert into chunks (id, data_id, content) values ('bbbbbbbb-2f3f-4bc9-8dba-ba397156cc16', 'aaaaaaaa-2f3f-4bc9-8dba-ba397156cc16','a chunk')")
Expand Down
2 changes: 0 additions & 2 deletions internal/collector/chunks_gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
func TestChunksGateway_Save(t *testing.T) {
testDb := testsupport.NewTestDb(t)
defer testDb.Close()
testDb.ClearTables()

gateway := collector.NewChunksGateway(testDb.DB)

Expand All @@ -30,7 +29,6 @@ func TestChunksGateway_Save(t *testing.T) {
func TestChunksGateway_Get(t *testing.T) {
testDb := testsupport.NewTestDb(t)
defer testDb.Close()
testDb.ClearTables()

gateway := collector.NewChunksGateway(testDb.DB)

Expand Down
1 change: 0 additions & 1 deletion internal/collector/chunks_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
func TestChunksService_SaveChunks(t *testing.T) {
testDb := testsupport.NewTestDb(t)
defer testDb.Close()
testDb.ClearTables()

chunksGateway := collector.NewChunksGateway(testDb.DB)
chunksService := collector.NewChunksService(DummyChunker{}, chunksGateway)
Expand Down
1 change: 0 additions & 1 deletion internal/collector/collect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ func TestCollector_Collect(t *testing.T) {

testDb := testsupport.NewTestDb(t)
defer testDb.Close()
testDb.ClearTables()
client := http.Client{}

extractor := feedsupport.NewExtractor(client)
Expand Down
2 changes: 0 additions & 2 deletions internal/collector/data_gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
func TestDataGateway_Save(t *testing.T) {
testDb := testsupport.NewTestDb(t)
defer testDb.Close()
testDb.ClearTables()

dataGateway := collector.NewDataGateway(testDb.DB)

Expand All @@ -30,7 +29,6 @@ func TestDataGateway_Save(t *testing.T) {
func TestDataGateway_Exists(t *testing.T) {
testDb := testsupport.NewTestDb(t)
defer testDb.Close()
testDb.ClearTables()

dataGateway := collector.NewDataGateway(testDb.DB)

Expand Down
8 changes: 2 additions & 6 deletions pkg/testsupport/test_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ func NewTestDb(t *testing.T) *TestDb {
assert.NoError(t, err, "unable to create test database")
})

println("created test database: " + testDbName)

return &TestDb{
DB: dbsupport.CreateConnection(fmt.Sprintf("postgres://starter:starter@localhost:5432/%s?sslmode=disable", testDbName)),
t: t,
Expand All @@ -39,12 +41,6 @@ func (tdb *TestDb) Close() {
})
}

func (tdb *TestDb) ClearTables() {
tdb.Execute("delete from embeddings")
tdb.Execute("delete from chunks")
tdb.Execute("delete from data")
}

func (tdb *TestDb) Execute(statement string, arguments ...any) {
_, err := tdb.DB.Exec(statement, arguments...)
assert.NoError(tdb.t, err)
Expand Down

0 comments on commit 6f30b16

Please sign in to comment.