"io/fs"
"math/rand"
"os"
- "reflect"
"testing"
)
Icon: &[]byte{0, 2},
Flags: &[]byte{0, 3},
UserName: []byte{0, 4},
+ Agreed: true,
+ },
+ uint16(2): {
+ ID: &[]byte{0, 2},
+ Icon: &[]byte{0, 2},
+ Flags: &[]byte{0, 3},
+ UserName: []byte{0, 4},
+ Agreed: true,
+ },
+ uint16(3): {
+ ID: &[]byte{0, 3},
+ Icon: &[]byte{0, 2},
+ Flags: &[]byte{0, 3},
+ UserName: []byte{0, 4},
+ Agreed: false,
},
},
},
fieldUsernameWithInfo,
[]byte{00, 01, 00, 02, 00, 03, 00, 02, 00, 04},
),
+ NewField(
+ fieldUsernameWithInfo,
+ []byte{00, 02, 00, 02, 00, 03, 00, 02, 00, 04},
+ ),
},
},
},
t.Errorf("HandleGetUserNameList() error = %v, wantErr %v", err, tt.wantErr)
return
}
- if !reflect.DeepEqual(got, tt.want) {
- t.Errorf("HandleGetUserNameList() got = %v, want %v", got, tt.want)
- }
+ assert.Equal(t, tt.want, got)
})
}
}
ID: &[]byte{0x00, 0x01},
Server: &Server{
Config: &Config{
- FileRoot: func() string { path, _ := os.Getwd(); return path + "/test/config/Files" }(),
+ FileRoot: func() string {
+ path, _ := os.Getwd()
+ return path + "/test/config/Files"
+ }(),
},
},
},
Fields: []Field{
NewField(fieldFileName, []byte("testfile.txt")),
NewField(fieldFileTypeString, []byte("TEXT")),
- NewField(fieldFileCreatorString, []byte("TTXT")),
- NewField(fieldFileComment, []byte("TODO")),
+ NewField(fieldFileCreatorString, []byte("ttxt")),
+ NewField(fieldFileComment, []byte{}),
NewField(fieldFileType, []byte("TEXT")),
- NewField(fieldFileCreateDate, []byte{0x07, 0x70, 0x00, 0x00, 0xba, 0x74, 0x24, 0x73}),
- NewField(fieldFileModifyDate, []byte{0x07, 0x70, 0x00, 0x00, 0xba, 0x74, 0x24, 0x73}),
+ NewField(fieldFileCreateDate, make([]byte, 8)),
+ NewField(fieldFileModifyDate, make([]byte, 8)),
NewField(fieldFileSize, []byte{0x0, 0x0, 0x0, 0x17}),
},
},
t.Errorf("HandleGetFileInfo() error = %v, wantErr %v", err, tt.wantErr)
return
}
+
+ // Clear the file timestamp fields to work around problems running the tests in multiple timezones
+ // TODO: revisit how to test this by mocking the stat calls
+ gotRes[0].Fields[5].Data = make([]byte, 8)
+ gotRes[0].Fields[6].Data = make([]byte, 8)
if !assert.Equal(t, tt.wantRes, gotRes) {
t.Errorf("HandleGetFileInfo() gotRes = %v, want %v", gotRes, tt.wantRes)
}