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

Add test if downloaded file exists after download #1227

Closed

Conversation

dithmer
Copy link
Contributor

@dithmer dithmer commented Dec 26, 2022

In this pull request, there is simply logic added to improve testing of downloading files into a directory.

Copy link
Member

@ZekeLu ZekeLu left a comment

Choose a reason for hiding this comment

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

Thank you!

chromedp_test.go Outdated Show resolved Hide resolved
chromedp_test.go Outdated Show resolved Hide resolved
@dithmer
Copy link
Contributor Author

dithmer commented Dec 27, 2022

Thank you for the feedback, I changed your hints. Anything else I can do here?

Copy link
Member

@ZekeLu ZekeLu left a comment

Choose a reason for hiding this comment

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

Thanks!

// the directory.
select {
case <-ctx.Done():
t.Fatal("chromedp context is done, before download was finished")
Copy link
Member

Choose a reason for hiding this comment

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

Replace this line with:

t.Fatalf("unexpected error: %v", ctx.Err())

Comment on lines +682 to +690
path := filepath.Join(dir, guid)

if _, err := os.Stat(path); err != nil {
if errors.Is(err, os.ErrNotExist) {
t.Fatal("Downloaded file does not exist")
}

t.Fatal("Unknown error while checking downloaded file")
}
Copy link
Member

@ZekeLu ZekeLu Dec 28, 2022

Choose a reason for hiding this comment

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

Replace the lines with:

if _, err := os.Stat(filepath.Join(dir, guid)); err != nil {
	t.Fatalf("want error nil, got: %v", err)
}

@ZekeLu
Copy link
Member

ZekeLu commented Jan 10, 2023

Merged.

@ZekeLu ZekeLu closed this Jan 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants