Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: uploads cleanup #3743

Merged
merged 4 commits into from
Aug 18, 2023
Merged

chore: uploads cleanup #3743

merged 4 commits into from
Aug 18, 2023

Conversation

achettyiitr
Copy link
Member

@achettyiitr achettyiitr commented Aug 14, 2023

Description

  • Using DI instead of Global variables.
  • Removed warehouse.Init().

Linear Ticket

Security

  • The code changed/added as part of this pull request won't create any security issues with how the software is being used.

@codecov
Copy link

codecov bot commented Aug 16, 2023

Codecov Report

Patch coverage: 79.00% and project coverage change: -0.12% ⚠️

Comparison is base (ff80a1d) 68.78% compared to head (72e9f66) 68.66%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3743      +/-   ##
==========================================
- Coverage   68.78%   68.66%   -0.12%     
==========================================
  Files         345      346       +1     
  Lines       51917    51939      +22     
==========================================
- Hits        35711    35666      -45     
- Misses      13907    13970      +63     
- Partials     2299     2303       +4     
Files Changed Coverage Δ
runner/runner.go 69.42% <ø> (-0.13%) ⬇️
warehouse/upload_stats.go 58.53% <71.42%> (ø)
warehouse/upload.go 71.45% <75.00%> (-0.42%) ⬇️
warehouse/integrations/config/config.go 100.00% <100.00%> (ø)
warehouse/router.go 87.11% <100.00%> (+0.02%) ⬆️
warehouse/slave_worker.go 80.45% <100.00%> (+0.11%) ⬆️
warehouse/slave_worker_job.go 85.62% <100.00%> (+0.04%) ⬆️
warehouse/warehouse.go 54.93% <100.00%> (-0.07%) ⬇️

... and 8 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@fracasula fracasula left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice 👍

Comment on lines 31 to 49
pool, err := dockertest.NewPool("")
require.NoError(t, err)

pgResource, err := resource.SetupPostgres(pool, t)
require.NoError(t, err)

t.Log("db:", pgResource.DBDsn)

err = (&migrator.Migrator{
Handle: pgResource.DB,
MigrationsTable: "wh_schema_migrations",
}).Migrate("warehouse")
require.NoError(t, err)

sqlStatement, err := os.ReadFile("testdata/sql/stats_test.sql")
require.NoError(t, err)

_, err = pgResource.DB.Exec(string(sqlStatement))
require.NoError(t, err)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could remove some duplicated code in these tests by using a common setup function:

func setupUploadTest(t testing.TB, migrationsPath string) *sql.DB {
	pool, err := dockertest.NewPool("")
	require.NoError(t, err)

	pgResource, err := resource.SetupPostgres(pool, t)
	require.NoError(t, err)

	t.Log("db:", pgResource.DBDsn)

	err = (&migrator.Migrator{
		Handle:          pgResource.DB,
		MigrationsTable: "wh_schema_migrations",
	}).Migrate("warehouse")
	require.NoError(t, err)

	sqlStatement, err := os.ReadFile(migrationsPath)
	require.NoError(t, err)

	_, err = pgResource.DB.Exec(string(sqlStatement))
	require.NoError(t, err)

	return pgResource.DB
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants