■ ■ ■ ■ ■ ■
syft/file/metadata_cataloger_test.go
skipped 3 lines 4 4 "flag" 5 5 "os" 6 6 "testing" 7 - "time" 8 7 9 8 "github.com/stretchr/testify/assert" 10 9 "github.com/stretchr/testify/require" skipped 41 lines 52 51 path: "/file-1.txt", 53 52 exists: true, 54 53 expected: source.FileMetadata{ 54 + FileInfo: file.ManualInfo{ 55 + NameValue: "file-1.txt", 56 + ModeValue: 0644, 57 + SizeValue: 7, 58 + }, 55 59 Path: "/file-1.txt", 56 - Mode: 0644, 57 60 Type: file.TypeRegular, 58 61 UserID: 1, 59 62 GroupID: 2, 60 - Size: 7, 61 63 MIMEType: "text/plain", 62 64 }, 63 65 }, skipped 1 lines 65 67 path: "/hardlink-1", 66 68 exists: true, 67 69 expected: source.FileMetadata{ 70 + FileInfo: file.ManualInfo{ 71 + NameValue: "hardlink-1", 72 + ModeValue: 0644, 73 + }, 68 74 Path: "/hardlink-1", 69 - Mode: 0644, 70 75 Type: file.TypeHardLink, 71 76 LinkDestination: "file-1.txt", 72 77 UserID: 1, skipped 5 lines 78 83 path: "/symlink-1", 79 84 exists: true, 80 85 expected: source.FileMetadata{ 81 - Path: "/symlink-1", 82 - Mode: 0777 | os.ModeSymlink, 86 + Path: "/symlink-1", 87 + FileInfo: file.ManualInfo{ 88 + NameValue: "symlink-1", 89 + ModeValue: 0777 | os.ModeSymlink, 90 + }, 83 91 Type: file.TypeSymLink, 84 92 LinkDestination: "file-1.txt", 85 93 UserID: 0, skipped 5 lines 91 99 path: "/char-device-1", 92 100 exists: true, 93 101 expected: source.FileMetadata{ 94 - Path: "/char-device-1", 95 - Mode: 0644 | os.ModeDevice | os.ModeCharDevice, 102 + Path: "/char-device-1", 103 + FileInfo: file.ManualInfo{ 104 + NameValue: "char-device-1", 105 + ModeValue: 0644 | os.ModeDevice | os.ModeCharDevice, 106 + }, 96 107 Type: file.TypeCharacterDevice, 97 108 UserID: 0, 98 109 GroupID: 0, skipped 4 lines 103 114 path: "/block-device-1", 104 115 exists: true, 105 116 expected: source.FileMetadata{ 106 - Path: "/block-device-1", 107 - Mode: 0644 | os.ModeDevice, 117 + Path: "/block-device-1", 118 + FileInfo: file.ManualInfo{ 119 + NameValue: "block-device-1", 120 + ModeValue: 0644 | os.ModeDevice, 121 + }, 108 122 Type: file.TypeBlockDevice, 109 123 UserID: 0, 110 124 GroupID: 0, skipped 4 lines 115 129 path: "/fifo-1", 116 130 exists: true, 117 131 expected: source.FileMetadata{ 118 - Path: "/fifo-1", 119 - Mode: 0644 | os.ModeNamedPipe, 132 + Path: "/fifo-1", 133 + FileInfo: file.ManualInfo{ 134 + NameValue: "fifo-1", 135 + ModeValue: 0644 | os.ModeNamedPipe, 136 + }, 120 137 Type: file.TypeFIFO, 121 138 UserID: 0, 122 139 GroupID: 0, skipped 4 lines 127 144 path: "/bin", 128 145 exists: true, 129 146 expected: source.FileMetadata{ 130 - Path: "/bin", 131 - Mode: 0755 | os.ModeDir, 147 + Path: "/bin", 148 + FileInfo: file.ManualInfo{ 149 + NameValue: "bin", 150 + ModeValue: 0755 | os.ModeDir, 151 + }, 132 152 Type: file.TypeDirectory, 133 153 UserID: 0, 134 154 GroupID: 0, 135 155 MIMEType: "", 136 - IsDir: true, 137 156 }, 138 157 }, 139 158 } skipped 6 lines 146 165 l := source.NewLocationFromImage(test.path, *ref.Reference, img) 147 166 148 167 if _, ok := actual[l.Coordinates]; ok { 149 - redact := actual[l.Coordinates] 150 - redact.ModTime = time.Time{} 151 - actual[l.Coordinates] = redact 168 + // we're not interested in keeping the test fixtures up to date with the latest file modification times 169 + // thus ModTime is not under test 170 + fi := test.expected.FileInfo.(file.ManualInfo) 171 + fi.ModTimeValue = actual[l.Coordinates].ModTime() 172 + test.expected.FileInfo = fi 152 173 } 153 174 154 - assert.Equal (t, test.expected, actual[l.Coordinates], " mismatched metadata " ) 155 - 175 + assert.True (t, test.expected. Equal ( actual[l.Coordinates]) ) 156 176 }) 157 177 } 158 178 skipped 2 lines