package hotline
import (
+ "io"
"reflect"
"testing"
)
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"),
},
},
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"),
},
},
func TestFileHeader_Payload(t *testing.T) {
type fields struct {
- Size []byte
- Type []byte
+ Size [2]byte
+ Type [2]byte
FilePath []byte
}
tests := []struct {
{
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{
Type: tt.fields.Type,
FilePath: tt.fields.FilePath,
}
- if got := fh.Payload(); !reflect.DeepEqual(got, tt.want) {
- t.Errorf("Payload() = %v, want %v", got, tt.want)
+ got, _ := io.ReadAll(fh)
+ if !reflect.DeepEqual(got, tt.want) {
+ t.Errorf("Read() = %v, want %v", got, tt.want)
}
})
}