X-Git-Url: https://git.r.bdr.sh/rbdr/mobius/blobdiff_plain/2728d12b6169a978aa3dc2e35390923d2eecd295..3c9b1dcdf40474396a3b035d548417b84a123164:/hotline/transaction_handlers_test.go diff --git a/hotline/transaction_handlers_test.go b/hotline/transaction_handlers_test.go index f8d3b2e..7c5ee43 100644 --- a/hotline/transaction_handlers_test.go +++ b/hotline/transaction_handlers_test.go @@ -5,7 +5,6 @@ import ( "io/fs" "math/rand" "os" - "reflect" "testing" ) @@ -227,6 +226,21 @@ func TestHandleGetUserNameList(t *testing.T) { 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, }, }, }, @@ -249,6 +263,10 @@ func TestHandleGetUserNameList(t *testing.T) { 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}, + ), }, }, }, @@ -262,9 +280,7 @@ func TestHandleGetUserNameList(t *testing.T) { 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) }) } } @@ -469,7 +485,10 @@ func TestHandleGetFileInfo(t *testing.T) { 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" + }(), }, }, }, @@ -491,10 +510,10 @@ func TestHandleGetFileInfo(t *testing.T) { NewField(fieldFileName, []byte("testfile.txt")), NewField(fieldFileTypeString, []byte("TEXT")), NewField(fieldFileCreatorString, []byte("ttxt")), - NewField(fieldFileComment, []byte("TODO")), + 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}), }, }, @@ -511,6 +530,11 @@ func TestHandleGetFileInfo(t *testing.T) { 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) }