X-Git-Url: https://git.r.bdr.sh/rbdr/mobius/blobdiff_plain/8ff2b66d1583b38298dfa415588df89631023695..4fa4a57c4352f703958c3c5cb8dcd2b56cb35882:/hotline/file_header_test.go?ds=sidebyside diff --git a/hotline/file_header_test.go b/hotline/file_header_test.go index 99fe4e4..308d6b9 100644 --- a/hotline/file_header_test.go +++ b/hotline/file_header_test.go @@ -1,6 +1,7 @@ package hotline import ( + "io" "reflect" "testing" ) @@ -22,8 +23,8 @@ func TestNewFileHeader(t *testing.T) { isDir: false, }, want: FileHeader{ - Size: []byte{0x00, 0x0a}, - Type: []byte{0x00, 0x00}, + Size: [2]byte{0x00, 0x0a}, + Type: [2]byte{0x00, 0x00}, FilePath: EncodeFilePath("foo"), }, }, @@ -34,8 +35,8 @@ func TestNewFileHeader(t *testing.T) { isDir: true, }, want: FileHeader{ - Size: []byte{0x00, 0x0a}, - Type: []byte{0x00, 0x01}, + Size: [2]byte{0x00, 0x0a}, + Type: [2]byte{0x00, 0x01}, FilePath: EncodeFilePath("foo"), }, }, @@ -51,8 +52,8 @@ func TestNewFileHeader(t *testing.T) { func TestFileHeader_Payload(t *testing.T) { type fields struct { - Size []byte - Type []byte + Size [2]byte + Type [2]byte FilePath []byte } tests := []struct { @@ -63,8 +64,8 @@ func TestFileHeader_Payload(t *testing.T) { { name: "has expected payload bytes", fields: fields{ - Size: []byte{0x00, 0x0a}, - Type: []byte{0x00, 0x00}, + Size: [2]byte{0x00, 0x0a}, + Type: [2]byte{0x00, 0x00}, FilePath: EncodeFilePath("foo"), }, want: []byte{ @@ -84,7 +85,8 @@ func TestFileHeader_Payload(t *testing.T) { Type: tt.fields.Type, FilePath: tt.fields.FilePath, } - if got := fh.Payload(); !reflect.DeepEqual(got, tt.want) { + got, _ := io.ReadAll(fh) + if !reflect.DeepEqual(got, tt.want) { t.Errorf("Read() = %v, want %v", got, tt.want) } })