Skip to content

Commit bb277b5

Browse files
committed
Add Test Case For Empty File That Can't Be Hashed
1 parent 169d6c1 commit bb277b5

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Diff for: script_test.go

+11
Original file line numberDiff line numberDiff line change
@@ -2109,6 +2109,17 @@ func TestHash_ReturnsErrorGivenReadErrorOnPipe(t *testing.T) {
21092109
}
21102110
}
21112111

2112+
func TestHashSums_OutputsEmptyStringForFileThatCannotBeHashed(t *testing.T) {
2113+
got, err := script.Echo("file_does_not_exist.txt").HashSums(sha256.New()).String()
2114+
if err != nil {
2115+
t.Fatal(err)
2116+
}
2117+
want := ""
2118+
if got != want {
2119+
t.Errorf("want %q, got %q", want, got)
2120+
}
2121+
}
2122+
21122123
func ExampleArgs() {
21132124
script.Args().Stdout()
21142125
// prints command-line arguments

0 commit comments

Comments
 (0)