From 29f329aedcdcf4e07a6dc3d9161439dd35ecfe11 Mon Sep 17 00:00:00 2001 From: Jeff Halter <868228+jhalter@users.noreply.github.com> Date: Wed, 25 May 2022 17:44:55 -0700 Subject: 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. --- hotline/flattened_file_object_test.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'hotline/flattened_file_object_test.go') diff --git a/hotline/flattened_file_object_test.go b/hotline/flattened_file_object_test.go index 5bbaf1d..12b6d32 100644 --- a/hotline/flattened_file_object_test.go +++ b/hotline/flattened_file_object_test.go @@ -43,7 +43,7 @@ func TestNewFlattenedFileObject(t *testing.T) { want: &flattenedFileObject{ FlatFileHeader: NewFlatFileHeader(), FlatFileInformationForkHeader: FlatFileInformationForkHeader{}, - FlatFileInformationFork: NewFlatFileInformationFork("testfile.txt"), + FlatFileInformationFork: NewFlatFileInformationFork("testfile.txt", make([]byte, 8)), FlatFileDataForkHeader: FlatFileDataForkHeader{ ForkType: []byte("DATA"), CompressionType: []byte{0, 0, 0, 0}, @@ -67,9 +67,14 @@ func TestNewFlattenedFileObject(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { got, err := NewFlattenedFileObject(tt.args.fileRoot, tt.args.filePath, tt.args.fileName) - if !tt.wantErr(t, err, fmt.Sprintf("NewFlattenedFileObject(%v, %v, %v)", tt.args.fileRoot, tt.args.filePath, tt.args.fileName)) { + if tt.wantErr(t, err, fmt.Sprintf("NewFlattenedFileObject(%v, %v, %v)", tt.args.fileRoot, tt.args.filePath, tt.args.fileName)) { 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 + got.FlatFileInformationFork.CreateDate = make([]byte, 8) + got.FlatFileInformationFork.ModifyDate = make([]byte, 8) assert.Equalf(t, tt.want, got, "NewFlattenedFileObject(%v, %v, %v)", tt.args.fileRoot, tt.args.filePath, tt.args.fileName) }) } -- cgit