Skip to content

Commit 8ce97b0

Browse files
committed
Resolve duplication
1 parent 2f5506c commit 8ce97b0

File tree

4 files changed

+8
-297
lines changed

4 files changed

+8
-297
lines changed

plugins/src/main/java/com/google/firebase/gradle/plugins/report/TestReportGenerator.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ import org.slf4j.LoggerFactory
3939
class TestReportGenerator(private val apiToken: String) {
4040
private val LOG: Logger = LoggerFactory.getLogger("firebase-test-report")
4141

42-
fun createReport(commitCount: Int) {
42+
fun createReport(outputFile: File, commitCount: Int) {
4343
val response: JsonObject =
4444
request(
4545
URI.create("https://api.github.com/graphql"),
@@ -75,10 +75,10 @@ class TestReportGenerator(private val apiToken: String) {
7575
?.int ?: throw RuntimeException("Couldn't find PR number for commit $obj"),
7676
)
7777
}
78-
outputReport(commits)
78+
outputReport(outputFile, commits)
7979
}
8080

81-
private fun outputReport(commits: List<ReportCommit>) {
81+
private fun outputReport(outputFile: File, commits: List<ReportCommit>) {
8282
val reports = commits.flatMap { commit -> parseTestReports(commit.sha) }
8383
val output = StringBuilder()
8484
output.append("### Unit Tests\n\n")
@@ -99,7 +99,7 @@ class TestReportGenerator(private val apiToken: String) {
9999
output.append("\n")
100100

101101
try {
102-
File("test-report.md").writeText(output.toString())
102+
outputFile.writeText(output.toString())
103103
} catch (e: Exception) {
104104
throw RuntimeException("Error writing report file", e)
105105
}

plugins/src/main/java/com/google/firebase/gradle/plugins/report/UnitTestReportPlugin.kt renamed to plugins/src/main/java/com/google/firebase/gradle/plugins/report/TestReportPlugin.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ import org.gradle.api.Plugin
2020
import org.gradle.api.Project
2121
import org.gradle.kotlin.dsl.register
2222

23-
class UnitTestReportPlugin : Plugin<Project> {
23+
class TestReportPlugin : Plugin<Project> {
2424
override fun apply(project: Project) {
25-
project.tasks.register<UnitTestReportTask>("generateTestReport") {
25+
project.tasks.register<TestReportTask>("generateTestReport") {
2626
outputFile.set(project.file("test-report.md"))
2727
commitCount.set(8 as Integer)
2828
apiToken.set(System.getenv("GH_TOKEN"))

plugins/src/main/java/com/google/firebase/gradle/plugins/report/UnitTestReportTask.kt renamed to plugins/src/main/java/com/google/firebase/gradle/plugins/report/TestReportTask.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import org.gradle.api.tasks.TaskAction
3131
* @property apiToken The GitHub API token with adequate permissions to read test result data and
3232
* execute GraphQL queries.
3333
*/
34-
abstract class UnitTestReportTask : DefaultTask() {
34+
abstract class TestReportTask : DefaultTask() {
3535
@get:OutputFile abstract val outputFile: RegularFileProperty
3636

3737
@get:Input abstract val commitCount: Property<Integer>
@@ -40,6 +40,6 @@ abstract class UnitTestReportTask : DefaultTask() {
4040

4141
@TaskAction
4242
fun make() {
43-
UnitTestReport(apiToken.get()).createReport(outputFile.asFile.get(), commitCount.get().toInt())
43+
TestReportGenerator(apiToken.get()).createReport(outputFile.asFile.get(), commitCount.get().toInt())
4444
}
4545
}

plugins/src/main/java/com/google/firebase/gradle/plugins/report/UnitTestReport.kt

Lines changed: 0 additions & 289 deletions
This file was deleted.

0 commit comments

Comments
 (0)