-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed Downsampling process; Fixed
runutil.CloseAndCaptureErr
(#1070)
* runutil. Simplified CloseWithErrCapture. Signed-off-by: Bartek Plotka <[email protected]> * Fixed Downsampling process; Fixed runutil.CloseAndCaptureErr Fixes #1065 Root cause: * runutil defered capture error function was not passing error properly so unit tests were passing, event though there was bug * streamed block write index cache requires index file which was not closed (saved) properly yet. Closers need to be closed to perform this. Signed-off-by: Bartek Plotka <[email protected]>
- Loading branch information
Showing
8 changed files
with
125 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package runutil | ||
|
||
import ( | ||
"github.com/pkg/errors" | ||
"io" | ||
"testing" | ||
) | ||
|
||
type testCloser struct { | ||
err error | ||
} | ||
|
||
func (c testCloser) Close() error { | ||
return c.err | ||
} | ||
|
||
func TestCloseWithErrCapture(t *testing.T) { | ||
for _, tcase := range []struct{ | ||
err error | ||
closer io.Closer | ||
|
||
expectedErrStr string | ||
}{ | ||
{ | ||
err: nil, | ||
closer: testCloser{err:nil}, | ||
expectedErrStr: "", | ||
}, | ||
{ | ||
err: errors.New("test"), | ||
closer: testCloser{err:nil}, | ||
expectedErrStr: "test", | ||
}, | ||
{ | ||
err: nil, | ||
closer: testCloser{err:errors.New("test")}, | ||
expectedErrStr: "close: test", | ||
}, | ||
{ | ||
err: errors.New("test"), | ||
closer: testCloser{err:errors.New("test")}, | ||
expectedErrStr: "2 errors: test; close: test", | ||
}, | ||
}{ | ||
if ok := t.Run("", func(t *testing.T) { | ||
ret := tcase.err | ||
CloseWithErrCapture(&ret, tcase.closer, "close") | ||
|
||
if tcase.expectedErrStr == "" { | ||
if ret != nil { | ||
t.Error("Expected error to be nil") | ||
t.Fail() | ||
} | ||
} else { | ||
if ret == nil { | ||
t.Error("Expected error to be not nil") | ||
t.Fail() | ||
} | ||
|
||
if tcase.expectedErrStr != ret.Error() { | ||
t.Errorf("%s != %s", tcase.expectedErrStr, ret.Error()) | ||
t.Fail() | ||
} | ||
} | ||
|
||
}); !ok { | ||
return | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters