1
0
Fork 0
mirror of https://github.com/vbatts/go-mtree.git synced 2025-10-04 04:31:00 +00:00
go-mtree/cksum_test.go
Aleksa Sarai 3252a4ad82
test: migrate most tests to testify
testify makes most bog-standard test checks much easier to read and
maintain, and is quite widely used. It wasn't really well known back
when go-mtree was first written, but the migration is fairly
straight-forward for most tests.

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2025-09-20 12:43:45 +10:00

27 lines
590 B
Go

package mtree
import (
"os"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
var (
checkFile = "./testdata/source.mtree"
checkSum uint32 = 1048442895
checkSize = 9110
)
// testing that the cksum function matches that of cksum(1) utility (silly POSIX crc32)
func TestCksum(t *testing.T) {
fh, err := os.Open(checkFile)
require.NoError(t, err)
defer fh.Close()
sum, i, err := cksum(fh)
require.NoError(t, err)
assert.Equal(t, checkSize, i, "checksum size mismatch")
assert.Equal(t, checkSum, sum, "checksum mismatch")
}