Skip to content

Commit 707250d

Browse files
authored
[CI-5225] Keep xcresult attachments in chronological order (#236)
* [CI-5225] Keep xcresult attachments in chronological order * Update test/converters/xcresult3/converter.go * fix: update converter tests
1 parent 7f17ac0 commit 707250d

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

test/converters/xcresult3/converter.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"os"
99
"path/filepath"
1010
"runtime"
11+
"sort"
1112
"strconv"
1213
"strings"
1314
"sync"
@@ -283,7 +284,13 @@ func extractAttachments(xcresultPath, outputPath string) (map[string][]string, e
283284

284285
var fileCounterMap = make(map[string]int)
285286
for _, attachmentDetail := range manifest {
286-
for _, attachment := range attachmentDetail.Attachments {
287+
attachments := attachmentDetail.Attachments
288+
289+
sort.Slice(attachments, func(i, j int) bool {
290+
return time.Time(attachments[i].Timestamp).Before(time.Time(attachments[j].Timestamp))
291+
})
292+
293+
for _, attachment := range attachments {
287294
oldPath := filepath.Join(outputPath, attachment.ExportedFileName)
288295
newPath := filepath.Join(outputPath, attachment.SuggestedHumanReadableName)
289296

test/converters/xcresult3/converter_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,27 +93,27 @@ func TestConverter_XML(t *testing.T) {
9393
Property: []testreport.Property{
9494
{
9595
Name: "attachment_0",
96-
Value: "Screenshot 2022-02-10 at 02.57.47 PM.jpeg",
96+
Value: "Screenshot 2022-02-10 at 02.57.39 PM.jpeg",
9797
},
9898
{
9999
Name: "attachment_1",
100-
Value: "Screenshot 2022-02-10 at 02.57.47 PM (1).jpeg",
100+
Value: "Screenshot 2022-02-10 at 02.57.39 PM (1).jpeg",
101101
},
102102
{
103103
Name: "attachment_2",
104-
Value: "Screenshot 2022-02-10 at 02.57.47 PM (2).jpeg",
104+
Value: "Screenshot 2022-02-10 at 02.57.44 PM.jpeg",
105105
},
106106
{
107107
Name: "attachment_3",
108-
Value: "Screenshot 2022-02-10 at 02.57.39 PM.jpeg",
108+
Value: "Screenshot 2022-02-10 at 02.57.47 PM.jpeg",
109109
},
110110
{
111111
Name: "attachment_4",
112-
Value: "Screenshot 2022-02-10 at 02.57.44 PM.jpeg",
112+
Value: "Screenshot 2022-02-10 at 02.57.47 PM (1).jpeg",
113113
},
114114
{
115115
Name: "attachment_5",
116-
Value: "Screenshot 2022-02-10 at 02.57.39 PM (1).jpeg",
116+
Value: "Screenshot 2022-02-10 at 02.57.47 PM (2).jpeg",
117117
},
118118
},
119119
},
@@ -176,11 +176,11 @@ func TestConverter_XML(t *testing.T) {
176176
Property: []testreport.Property{
177177
{
178178
Name: "attachment_0",
179-
Value: "Screenshot 2021-02-09 at 08.35.52 AM.jpeg",
179+
Value: "Screenshot 2021-02-09 at 08.35.51 AM.jpeg",
180180
},
181181
{
182182
Name: "attachment_1",
183-
Value: "Screenshot 2021-02-09 at 08.35.51 AM.jpeg",
183+
Value: "Screenshot 2021-02-09 at 08.35.52 AM.jpeg",
184184
},
185185
{
186186
Name: "attachment_2",

0 commit comments

Comments
 (0)