1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/pkg/tarsum
Kir Kolyshkin 05cbe23db9 pkg/tarsum: fix unit test for Go 1.11+
Since go-1.11beta1 archive/tar, tar headers with Typeflag == TypeRegA
(numeric 0) (which is the default unless explicitly initialized) are
modified to have Typeflag set to either tar.TypeReg (character value
'0', not numeric 0) or tar.TypeDir (character value '5') [1].
This results in different Typeflag value in the resulting header,
leading to a different Checksum, and causing the following test
case errors:

> 12:09:14 --- FAIL: TestTarSums (0.05s)
> 12:09:14 tarsum_test.go:393: expecting
> [tarsum+sha256:8bf12d7e67c51ee2e8306cba569398b1b9f419969521a12ffb9d8875e8836738],
> but got
> [tarsum+sha256:75258b2c5dcd9adfe24ce71eeca5fc5019c7e669912f15703ede92b1a60cb11f]
> ... (etc.)

All the other code explicitly sets the Typeflag field, but this test
case is not, causing the incompatibility with Go 1.11. Therefore,
the fix is to set TypeReg explicitly, and change the expected checksums
in test cases).

Alternatively, we can vendor archive/tar again (for the 100th time),
but given that the issue is limited to the particular test case it
does not make sense.

This fixes the test for all Go versions.

[1] https://go-review.googlesource.com/c/go/+/85656

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2018-07-19 10:38:45 +03:00
..
testdata
builder_context.go Add canonical import comment 2018-02-05 16:51:57 -05:00
builder_context_test.go Add canonical import comment 2018-02-05 16:51:57 -05:00
fileinfosums.go Add canonical import comment 2018-02-05 16:51:57 -05:00
fileinfosums_test.go Add canonical import comment 2018-02-05 16:51:57 -05:00
tarsum.go Fix tarsum for go 1.10 2018-04-12 13:34:14 -07:00
tarsum_spec.md fix common misspell 2016-02-11 15:49:36 -08:00
tarsum_test.go pkg/tarsum: fix unit test for Go 1.11+ 2018-07-19 10:38:45 +03:00
versioning.go Add canonical import comment 2018-02-05 16:51:57 -05:00
versioning_test.go Add canonical import comment 2018-02-05 16:51:57 -05:00
writercloser.go Add canonical import comment 2018-02-05 16:51:57 -05:00