Browse code

Add unit test for tarSum.Sum() with no data

Docker-DCO-1.1-Signed-off-by: Josh Hawn <josh.hawn@docker.com> (github: jlhawn)

Josh Hawn authored on 2014/11/20 05:15:20
Showing 1 changed files
... ...
@@ -230,6 +230,17 @@ func TestEmptyTar(t *testing.T) {
230 230
 	if resultSum != expectedSum {
231 231
 		t.Fatalf("expected [%s] but got [%s]", expectedSum, resultSum)
232 232
 	}
233
+
234
+	// Test without ever actually writing anything.
235
+	if ts, err = NewTarSum(bytes.NewReader([]byte{}), true, Version0); err != nil {
236
+		t.Fatal(err)
237
+	}
238
+
239
+	resultSum = ts.Sum(nil)
240
+
241
+	if resultSum != expectedSum {
242
+		t.Fatalf("expected [%s] but got [%s]", expectedSum, resultSum)
243
+	}
233 244
 }
234 245
 
235 246
 var (