diff options
| author | Jeff Halter <868228+jhalter@users.noreply.github.com> | 2022-05-25 17:44:55 -0700 |
|---|---|---|
| committer | Jeff Halter <868228+jhalter@users.noreply.github.com> | 2022-05-25 19:51:33 -0700 |
| commit | 29f329aedcdcf4e07a6dc3d9161439dd35ecfe11 (patch) | |
| tree | 9bc21e1e3ff6412f85af23fef7a885bafec8fe1e /hotline/transaction_handlers_test.go | |
| parent | c62f0b470f0ce33d5f52897f2cae7fd355f04b80 (diff) | |
Add partial support for file create/modify timestamps
This replaces hardcoded placeholder create/modify timestamps with the real times, mostly. Create time is OS specific, so for now I'm ignoring it at using the modify time as a stand-in.
Diffstat (limited to 'hotline/transaction_handlers_test.go')
| -rw-r--r-- | hotline/transaction_handlers_test.go | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/hotline/transaction_handlers_test.go b/hotline/transaction_handlers_test.go index f8d3b2e..b734049 100644 --- a/hotline/transaction_handlers_test.go +++ b/hotline/transaction_handlers_test.go @@ -469,7 +469,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" + }(), }, }, }, @@ -493,8 +496,8 @@ func TestHandleGetFileInfo(t *testing.T) { NewField(fieldFileCreatorString, []byte("ttxt")), NewField(fieldFileComment, []byte("TODO")), 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 +514,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) } |