Skip to content

Commit

Permalink
Return the meta after sorting and merging operations
Browse files Browse the repository at this point in the history
  • Loading branch information
f-meloni committed Feb 12, 2019
1 parent 6f3871e commit 5602d74
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
3 changes: 3 additions & 0 deletions source/dsl/DangerResults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ export function regularResults(results: DangerResults): DangerResults {
warnings: results.warnings.filter(m => !isInline(m)),
messages: results.messages.filter(m => !isInline(m)),
markdowns: results.markdowns.filter(m => !isInline(m)),
meta: results.meta,
}
}

Expand All @@ -139,6 +140,7 @@ export function mergeResults(results1: DangerResults, results2: DangerResults):
warnings: results1.warnings.concat(results2.warnings),
messages: results1.messages.concat(results2.messages),
markdowns: results1.markdowns.concat(results2.markdowns),
meta: results1.meta || results2.meta,
}
}

Expand Down Expand Up @@ -211,6 +213,7 @@ export function sortResults(results: DangerResults): DangerResults {
warnings: results.warnings.sort(sortByFile),
messages: results.messages.sort(sortByFile),
markdowns: results.markdowns.sort(sortByFile),
meta: results.meta,
}
}

Expand Down
8 changes: 8 additions & 0 deletions source/dsl/_tests/__snapshots__/DangerResults.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,10 @@ Object {
"message": "Message message2",
},
],
"meta": Object {
"runtimeHref": "http://danger.system/swift",
"runtimeName": "Swift",
},
"warnings": Array [
Object {
"message": "Warnings message1",
Expand Down Expand Up @@ -329,6 +333,10 @@ Object {
"message": "Message message3",
},
],
"meta": Object {
"runtimeHref": "http://danger.system/swift",
"runtimeName": "Swift",
},
"warnings": Array [
Object {
"file": "Test.swift",
Expand Down
16 changes: 16 additions & 0 deletions source/dsl/_tests/fixtures/ExampleDangerResults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ export const singleViolationSingleFileResults: DangerResults = {
warnings: [{ message: "Warnings message", file: "Test.swift", line: 10 }],
messages: [{ message: "Message message", file: "Test.swift", line: 10 }],
markdowns: [{ message: "Markdown message", file: "Test.swift", line: 10 }],
meta: {
runtimeHref: "http://danger.system/swift",
runtimeName: "Swift",
},
}

export const multipleViolationSingleFileResults: DangerResults = {
Expand All @@ -28,6 +32,10 @@ export const multipleViolationSingleFileResults: DangerResults = {
{ message: "Markdown message2", file: "Test.swift", line: 10 },
{ message: "Markdown message3", file: "Test.swift", line: 10 },
],
meta: {
runtimeHref: "http://danger.system/swift",
runtimeName: "Swift",
},
}

export const multipleViolationsMultipleFilesResults: DangerResults = {
Expand All @@ -51,6 +59,10 @@ export const multipleViolationsMultipleFilesResults: DangerResults = {
{ message: "Markdown message2", file: "Test.swift", line: 11 },
{ message: "Markdown message3", file: "Test.swift", line: 12 },
],
meta: {
runtimeHref: "http://danger.system/swift",
runtimeName: "Swift",
},
}

export const emptyDangerResults: DangerResults = {
Expand Down Expand Up @@ -108,6 +120,10 @@ export const regularAndInlineViolationsResults: DangerResults = {
{ message: "Markdown message2", file: "Test.swift", line: 10 },
{ message: "Markdown message3", file: "Test.swift", line: 10 },
],
meta: {
runtimeHref: "http://danger.system/swift",
runtimeName: "Swift",
},
}

export const unsortedInlineResults: DangerInlineResults[] = [
Expand Down

0 comments on commit 5602d74

Please sign in to comment.