8 func TestNewFileHeader(t *testing.T) {
19 name: "when path is file",
25 Size: []byte{0x00, 0x0a},
26 Type: []byte{0x00, 0x00},
27 FilePath: EncodeFilePath("foo"),
31 name: "when path is dir",
37 Size: []byte{0x00, 0x0a},
38 Type: []byte{0x00, 0x01},
39 FilePath: EncodeFilePath("foo"),
43 for _, tt := range tests {
44 t.Run(tt.name, func(t *testing.T) {
45 if got := NewFileHeader(tt.args.fileName, tt.args.isDir); !reflect.DeepEqual(got, tt.want) {
46 t.Errorf("NewFileHeader() = %v, want %v", got, tt.want)
52 func TestFileHeader_Payload(t *testing.T) {
64 name: "has expected payload bytes",
66 Size: []byte{0x00, 0x0a},
67 Type: []byte{0x00, 0x00},
68 FilePath: EncodeFilePath("foo"),
71 0x00, 0x0a, // total size
73 0x00, 0x01, // path item count
74 0x00, 0x00, // path separator
76 0x66, 0x6f, 0x6f, // "foo"
80 for _, tt := range tests {
81 t.Run(tt.name, func(t *testing.T) {
85 FilePath: tt.fields.FilePath,
87 if got := fh.Payload(); !reflect.DeepEqual(got, tt.want) {
88 t.Errorf("Read() = %v, want %v", got, tt.want)