-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Check if folder exists before attempting to copy folders #743
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.
Thanks for the PR!
modules/files/files.go
Outdated
return "", err | ||
} | ||
if !exists { | ||
return "", os.ErrNotExist |
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.
NIT: Could you create a new error that includes the path of the non-existent folder in the error message? That'll help quite a bit with debugging.
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.
fixed this to include the folderPath. I wonder if I should also use that same error message 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.
Yes please! In fact, we typically define a new type that implements the error
interface (has an Error()
method), so that (a) you can check if the error you got back was of a specific type, rather than doing string parsing and (b) you can re-use that error type in more than one place.
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.
got it, I created DirNotFoundError
. Let me know if that's what you were thinking!
t.Fatal(err) | ||
} | ||
if !exists { | ||
t.Fatal(os.ErrNotExist, fullTerraformModuleFolder) |
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.
Will this show a clear error message?
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.
This will result in:
TestTerraformAwsExamplePlan: test_structure.go:82: file does not exist ../no/examples/terraform-aws-example
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.
That's decent, but would be slightly better if it said "directory" instead of file. If you extract + reuse the error type as mentioned above, that'll do the trick.
@brikis98 Thanks for taking the time to review this, I appreciate it! |
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.
LGTM, thanks! I'll kick off tests now.
Ah, doh, I forgot we have a couple random test failures, and we're working on a fix now: #756. Let's get that merged first, and then I can re-run the tests here. |
Cool thanks! Let me know if I can help at all |
… failing faster and make debugging easier (files and test-structure)
I rebased this PR with master to pull in the test updates |
Thanks! I'll re-run tests now. |
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.
Tests passed! Merging now, thank you!
This PR attempts to close #738.
I ran through the unit tests that were affected by these changes. I'm not sure if the output is super useful for those but I also ran some of the automated tests that use
CopyTerraformFolderToTemp
which look good. I was unable to run the full automated test suite right now, but I can look at doing at later if needed.Here is the output from the automated test I did run:
https://gist.github.com/cbuto/13dd83b40d29503288b11192ee2c4149