-
Notifications
You must be signed in to change notification settings - Fork 33
Conversation
7037153
to
e88b5cb
Compare
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 grabbing this!
eed53f4
to
faec143
Compare
af782a4
to
f53a2fc
Compare
e9cb61b
to
2f3bec4
Compare
Codecov Report
@@ Coverage Diff @@
## master #612 +/- ##
==========================================
+ Coverage 51.73% 51.94% +0.21%
==========================================
Files 95 95
Lines 3236 3267 +31
==========================================
+ Hits 1674 1697 +23
- Misses 1211 1216 +5
- Partials 351 354 +3
Continue to review full report at Codecov.
|
This looks really good @jmbrown412, nice job! |
a751aff
to
a1fe7ba
Compare
a1fe7ba
to
4ceebd7
Compare
04e254a
to
a6c843d
Compare
pkg/transfers/inbound/cleanup.go
Outdated
if err := deleteEmptyFiles(logger, agent, dl.dir, agent.InboundPath(), now, after); err != nil { | ||
el.Add(err) | ||
} | ||
if err := deleteEmptyFiles(logger, agent, dl.dir, agent.ReturnPath(), now, after); err != nil { | ||
el.Add(err) | ||
} |
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.
Up to you if you want to add this, but you could simplify to:
for _, path := range []string{agent.InboundPath(), agent.ReturnPath()} {
if err := deleteEmptyFiles(logger, agent, dl.dir, path, now, after); err != nil {
el.Add(err)
}
}
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.
I like this a lot better. Pushed
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.
We should be consistent with Cleanup
above. It's confusing when different coding styles are used within a file.
} | ||
|
||
func (m mockedFS) Name() string { | ||
panic("implement me") |
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.
Should these just return "dummy" values, like return "name"
instead of calling panic?
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.
They totally should even though they aren't being used. I'll update these.
} | ||
} | ||
|
||
func Test_CleanupEmptyFiles_Not_Run_When_Config_Is_Zero(t *testing.T) { |
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.
I think these might be easier to read with fewer underscores.. Maybe something like TestCleanupEmptyFiles_notRunWhenConfigZero(t *testing.T)
?
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.
Agreed. I can clean these up here shortly.
func Test_CleanupEmptyFiles_InboundPath_Success(t *testing.T) { | ||
agent := &upload.MockAgent{} | ||
|
||
dir, _ := ioutil.TempDir("", "clenaup-testing") |
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.
All instances of clenaup-testing
should be cleanup-testing
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.
Totally. Good catch.
func Test_CleanupEmptyFiles_ReturnPath_Success(t *testing.T) { | ||
agent := &upload.MockAgent{} | ||
|
||
dir, _ := ioutil.TempDir("", "clenaup-testing") |
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.
I think it'd be better to use t.TempDir()
here instead because it cleans up after itself.
ioutil TempDir:
It is the caller's responsibility to remove the directory when no longer needed.
Compare to testing TempDir:
The directory is automatically removed by Cleanup when the test and all its subtests complete.
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.
I'm not sure on this one. Since the code being tested actually cleans up the files, I'm not sure if having it cleaned up automatically is what we want. Maybe? Need to look into 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.
It kind of cleans up. It cleans up the files, but leaves the directory. I think the testing package's version of the method makes more sense since it's purpose built for tests.
t.Error("expected error") | ||
} | ||
|
||
if agent.DeletedFile != "inbound/empty_file.ach" { |
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 one's more of a nit, but I think tests cases and their output are easier to read when testify is used. As an example, this block could be replaced by assert.Equal(t, "inbound/empty_file.ach", agent.DeletedFile)
. If the test fails it will print out a nicely-formatted error message that lets you quickly see why the test failed.
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.
Good to know. I'll try it out and see how it goes. If it makes reading test output better, more informative, nicely formatted then that sounds great.
fb477cf
to
effcefb
Compare
This PR introduces logic to conditionally delete zero byte (empty) files that may exist on the remote server while a transfer is in place. We want to wait to delete these after a configurable amount of time.