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

Alter exposed functions that take contexts #58

Merged
merged 1 commit into from
Aug 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions speedtest/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,15 @@ var client = http.Client{}

// DownloadTest executes the test to measure download speed
func (s *Server) DownloadTest(savingMode bool) error {
return s.DownloadTestContext(context.Background(), savingMode, dlWarmUp, downloadRequest)
return s.downloadTestContext(context.Background(), savingMode, dlWarmUp, downloadRequest)
}

// DownloadTestContext executes the test to measure download speed, observing the given context.
func (s *Server) DownloadTestContext(
func (s *Server) DownloadTestContext(ctx context.Context, savingMode bool) error {
return s.downloadTestContext(ctx, savingMode, dlWarmUp, downloadRequest)
}

func (s *Server) downloadTestContext(
ctx context.Context,
savingMode bool,
dlWarmUp downloadWarmUpFunc,
Expand Down Expand Up @@ -98,11 +102,14 @@ func (s *Server) DownloadTestContext(

// UploadTest executes the test to measure upload speed
func (s *Server) UploadTest(savingMode bool) error {
return s.UploadTestContext(context.Background(), savingMode, ulWarmUp, uploadRequest)
return s.uploadTestContext(context.Background(), savingMode, ulWarmUp, uploadRequest)
}

// UploadTestContext executes the test to measure upload speed, observing the given context.
func (s *Server) UploadTestContext(
func (s *Server) UploadTestContext(ctx context.Context, savingMode bool) error {
return s.uploadTestContext(ctx, savingMode, ulWarmUp, uploadRequest)
}
func (s *Server) uploadTestContext(
ctx context.Context,
savingMode bool,
ulWarmUp uploadWarmUpFunc,
Expand Down
8 changes: 4 additions & 4 deletions speedtest/request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func TestDownloadTestContext(t *testing.T) {
Latency: latency,
}

err := server.DownloadTestContext(
err := server.downloadTestContext(
context.Background(),
false,
mockWarmUp,
Expand All @@ -35,7 +35,7 @@ func TestDownloadTestContextSavingMode(t *testing.T) {
Latency: latency,
}

err := server.DownloadTestContext(
err := server.downloadTestContext(
context.Background(),
true,
mockWarmUp,
Expand All @@ -56,7 +56,7 @@ func TestUploadTestContext(t *testing.T) {
Latency: latency,
}

err := server.UploadTestContext(
err := server.uploadTestContext(
context.Background(),
false,
mockWarmUp,
Expand All @@ -77,7 +77,7 @@ func TestUploadTestContextSavingMode(t *testing.T) {
Latency: latency,
}

err := server.UploadTestContext(
err := server.uploadTestContext(
context.Background(),
true,
mockWarmUp,
Expand Down