9 func TestNewFileHeader(t *testing.T) {
20 name: "when path is file",
26 Size: [2]byte{0x00, 0x0a},
27 Type: [2]byte{0x00, 0x00},
28 FilePath: EncodeFilePath("foo"),
32 name: "when path is dir",
38 Size: [2]byte{0x00, 0x0a},
39 Type: [2]byte{0x00, 0x01},
40 FilePath: EncodeFilePath("foo"),
44 for _, tt := range tests {
45 t.Run(tt.name, func(t *testing.T) {
46 if got := NewFileHeader(tt.args.fileName, tt.args.isDir); !reflect.DeepEqual(got, tt.want) {
47 t.Errorf("NewFileHeader() = %v, want %v", got, tt.want)
53 func TestFileHeader_Payload(t *testing.T) {
65 name: "has expected payload bytes",
67 Size: [2]byte{0x00, 0x0a},
68 Type: [2]byte{0x00, 0x00},
69 FilePath: EncodeFilePath("foo"),
72 0x00, 0x0a, // total size
74 0x00, 0x01, // path item count
75 0x00, 0x00, // path separator
77 0x66, 0x6f, 0x6f, // "foo"
81 for _, tt := range tests {
82 t.Run(tt.name, func(t *testing.T) {
86 FilePath: tt.fields.FilePath,
88 got, _ := io.ReadAll(fh)
89 if !reflect.DeepEqual(got, tt.want) {
90 t.Errorf("Read() = %v, want %v", got, tt.want)