aboutsummaryrefslogtreecommitdiff
path: root/internal/hash/hash_test.go
blob: da3a4a6926fb3533d2cc3c7cbc6d6fb94535469b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package hash

import (
	"encoding/binary"
	"os"
	"testing"
)

func TestOpen(t *testing.T) {
	fd, err := os.Open("testdata/aliases.db")
	if err != nil {
		t.Fatal(err)
	}
	defer fd.Close()
	var hdr HashHdr
	if err := binary.Read(fd, binary.BigEndian, &hdr); err != nil {
		t.Fatal(err)
	}
	if hdr.Magic != Magic {
		t.Errorf("got %x, want %x", hdr.Magic, Magic)
	}
	if hdr.Version != Version {
		t.Errorf("got %x, want %x", hdr.Version, Version)
	}
	t.Logf("%+v", hdr)
}