]> git.r.bdr.sh - rbdr/mobius/blobdiff - hotline/file_path_test.go
Merge pull request #50 from jhalter/implement_delNewsItem_access_controls
[rbdr/mobius] / hotline / file_path_test.go
index 4c2f6db80c855e1741595ab5e1210b358afda4b4..c2fa66687b02366320007df690db485b1fdfe038 100644 (file)
@@ -5,7 +5,7 @@ import (
        "testing"
 )
 
        "testing"
 )
 
-func TestFilePath_UnmarshalBinary(t *testing.T) {
+func TestFilePath_Write(t *testing.T) {
        type args struct {
                b []byte
        }
        type args struct {
                b []byte
        }
@@ -41,12 +41,23 @@ func TestFilePath_UnmarshalBinary(t *testing.T) {
                        },
                        wantErr: false,
                },
                        },
                        wantErr: false,
                },
+               {
+                       name: "handles empty data payload",
+                       args: args{b: []byte{
+                               0x00, 0x00,
+                       }},
+                       want: FilePath{
+                               ItemCount: [2]byte{0x00, 0x00},
+                               Items:     []FilePathItem(nil),
+                       },
+                       wantErr: false,
+               },
        }
        for _, tt := range tests {
                t.Run(tt.name, func(t *testing.T) {
                        var fp FilePath
        }
        for _, tt := range tests {
                t.Run(tt.name, func(t *testing.T) {
                        var fp FilePath
-                       if err := fp.UnmarshalBinary(tt.args.b); (err != nil) != tt.wantErr {
-                               t.Errorf("UnmarshalBinary() error = %v, wantErr %v", err, tt.wantErr)
+                       if _, err := fp.Write(tt.args.b); (err != nil) != tt.wantErr {
+                               t.Errorf("Write() error = %v, wantErr %v", err, tt.wantErr)
                        }
                        if !assert.Equal(t, tt.want, fp) {
                                t.Errorf("Read() got = %v, want %v", fp, tt.want)
                        }
                        if !assert.Equal(t, tt.want, fp) {
                                t.Errorf("Read() got = %v, want %v", fp, tt.want)
@@ -78,7 +89,7 @@ func Test_readPath(t *testing.T) {
                                        0x61, 0x61, 0x61,
                                },
                        },
                                        0x61, 0x61, 0x61,
                                },
                        },
-                       want: "",
+                       want:    "",
                        wantErr: true,
                },
                {
                        wantErr: true,
                },
                {
@@ -87,7 +98,6 @@ func Test_readPath(t *testing.T) {
                                fileRoot: "/usr/local/var/mobius/Files",
                                filePath: nil,
                                fileName: []byte("foo"),
                                fileRoot: "/usr/local/var/mobius/Files",
                                filePath: nil,
                                fileName: []byte("foo"),
-
                        },
                        want: "/usr/local/var/mobius/Files/foo",
                },
                        },
                        want: "/usr/local/var/mobius/Files/foo",
                },
@@ -153,4 +163,4 @@ func Test_readPath(t *testing.T) {
                        }
                })
        }
                        }
                })
        }
-}
\ No newline at end of file
+}