aboutsummaryrefslogtreecommitdiff
path: root/hotline/file_header_test.go
diff options
context:
space:
mode:
authorJeff Halter <868228+jhalter@users.noreply.github.com>2024-06-09 13:56:29 -0700
committerJeff Halter <868228+jhalter@users.noreply.github.com>2024-06-09 14:05:15 -0700
commit9cf66aeafbcbb9237fedc2efc97cc2856eb60f7f (patch)
treec3139d8af2bd6ae106a1f619cad7d64f2ddea6db /hotline/file_header_test.go
parentb129b7cbc9fd9a9c11a77e5922861ef08893efa1 (diff)
Convert more bespoke methods to io.Reader/io.Writer interfaces
Diffstat (limited to 'hotline/file_header_test.go')
-rw-r--r--hotline/file_header_test.go20
1 files changed, 11 insertions, 9 deletions
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)
}
})