mirror of
https://github.com/vbatts/go-mtree.git
synced 2025-10-04 12:31:00 +00:00
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>
27 lines
590 B
Go
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")
|
|
}
|