Skip to content

Commit

Permalink
Setup Open Graph meta arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien Rollet committed Jan 11, 2019
1 parent 34f6b14 commit 6f75bae
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ struct HTMLTemplates
<head>
<meta charset=\"utf-8\">
<title>XCHTMLReport</title>
<title>XCTestHTMLReport</title>
<meta name=\"description\" content=\"Xcode Testing HTML Report\">
<meta property=\"og:title\" content=\"XCTestHTMLReport\" />
<meta property=\"og:image\" content=\"[[OG_IMAGE]]\" />
<meta property=\"og:description\" content=\"[[OG_DESCRIPTION]]\" />
<style type=\"text/css\">
Expand Down
26 changes: 23 additions & 3 deletions XCTestHTMLReport/XCTestHTMLReport/Classes/Models/Summary.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,19 @@ import Foundation
struct Summary
{
private let filename = "action_TestSummaries.plist"
private let validIconUrl = "https://raw.githubusercontent.com/applidium/XCTestHTMLReport/develop_ad/XCTestHTMLReport/XCTestHTMLReport/Resources/valid.png"
private let invalidIconUrl = "https://raw.githubusercontent.com/applidium/XCTestHTMLReport/develop_ad/XCTestHTMLReport/XCTestHTMLReport/Resources/invalid.png"

var runs = [Run]()
var totalNumberOfTests: Int {
return runs.reduce(0) { $0 + $1.numberOfTests }
}
var totalNumberOfPassedTests: Int {
return runs.reduce(0) { $0 + $1.numberOfPassedTests }
}
var totalNumberOfFailedTests: Int {
return runs.reduce(0) { $0 + $1.numberOfFailedTests }
}

init(roots: [String])
{
Expand Down Expand Up @@ -42,6 +53,14 @@ struct Summary
}
}
}

//MARK: - Private

private func isSummaryValid() -> Bool {
return runs.reduce(true) { (accumulator: Bool, run: Run) -> Bool in
return accumulator && run.status == .success
}
}
}

extension Summary: HTML
Expand All @@ -51,11 +70,12 @@ extension Summary: HTML
}

var htmlPlaceholderValues: [String: String] {
let isSummaryValid = self.isSummaryValid()
return [
"OG_IMAGE": isSummaryValid ? validIconUrl : invalidIconUrl,
"OG_DESCRIPTION": "Total test count : \(totalNumberOfTests). \(totalNumberOfPassedTests) passed, \(totalNumberOfFailedTests) failed.",
"DEVICES": runs.map { $0.runDestination.html }.joined(),
"RESULT_CLASS": runs.reduce(true, { (accumulator: Bool, run: Run) -> Bool in
return accumulator && run.status == .success
}) ? "success" : "failure",
"RESULT_CLASS": isSummaryValid ? "success" : "failure",
"RUNS": runs.map { $0.html }.joined()
]
}
Expand Down
5 changes: 4 additions & 1 deletion XCTestHTMLReport/XCTestHTMLReport/HTML/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@
<head>
<meta charset="utf-8">

<title>XCHTMLReport</title>
<title>XCTestHTMLReport</title>
<meta name="description" content="Xcode Testing HTML Report">
<meta property="og:title" content="XCTestHTMLReport" />
<meta property="og:image" content="[[OG_IMAGE]]" />
<meta property="og:description" content="[[OG_DESCRIPTION]]" />

<style type="text/css">

Expand Down

0 comments on commit 6f75bae

Please sign in to comment.