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
Add test if downloaded file exists after download #1227
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Thank you for the feedback, I changed your hints. Anything else I can do here? |
There was a problem hiding this 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") |
There was a problem hiding this comment.
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())
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") | ||
} |
There was a problem hiding this comment.
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)
}
Merged. |
In this pull request, there is simply logic added to improve testing of downloading files into a directory.