-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MBS-12101 Rework ownership plugin (#1249)
- Loading branch information
1 parent
b4d1b4b
commit 5576e5f
Showing
14 changed files
with
339 additions
and
403 deletions.
There are no files selected for viewing
231 changes: 0 additions & 231 deletions
231
...dle/code-ownership/src/gradleTest/kotlin/com/avito/android/CodeOwnershipValidationTest.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
.../gradle/code-ownership/src/gradleTest/kotlin/com/avito/android/ExportOwnershipInfoTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
package com.avito.android | ||
|
||
import com.avito.test.gradle.TestProjectGenerator | ||
import com.avito.test.gradle.dependencies.GradleDependency.Safe.CONFIGURATION.IMPLEMENTATION | ||
import com.avito.test.gradle.dependencies.GradleDependency.Safe.Companion.project | ||
import com.avito.test.gradle.gradlew | ||
import com.avito.test.gradle.module.AndroidAppModule | ||
import com.avito.test.gradle.module.AndroidLibModule | ||
import com.avito.test.gradle.module.KotlinModule | ||
import com.avito.test.gradle.plugin.plugins | ||
import org.junit.Assert.assertEquals | ||
import org.junit.Assert.assertTrue | ||
import org.junit.jupiter.api.Test | ||
import org.junit.jupiter.api.io.TempDir | ||
import java.io.File | ||
|
||
internal class ExportOwnershipInfoTest { | ||
|
||
@Test | ||
internal fun `ownership exporting to csv file - works correctly`(@TempDir projectDir: File) { | ||
TestProjectGenerator( | ||
name = "rootapp", | ||
plugins = plugins { | ||
id("com.avito.android.code-ownership") | ||
}, | ||
modules = listOf( | ||
AndroidAppModule( | ||
"app", | ||
imports = listOf("import com.avito.android.model.Owner"), | ||
plugins = plugins { | ||
id("com.avito.android.module-types") | ||
}, | ||
dependencies = setOf( | ||
project( | ||
path = ":feature", | ||
configuration = IMPLEMENTATION | ||
), | ||
project( | ||
path = ":common", | ||
configuration = IMPLEMENTATION | ||
) | ||
), | ||
buildGradleExtra = """ | ||
|class Speed implements Owner { | ||
| String toString() { return "Speed" } | ||
|} | ||
|def speed = new Speed() { } | ||
| | ||
|ownership { | ||
| owners = [speed] | ||
|} | ||
""".trimMargin() | ||
), | ||
AndroidLibModule( | ||
name = "feature", | ||
imports = listOf("import com.avito.android.model.Owner"), | ||
plugins = plugins { | ||
id("com.avito.android.module-types") | ||
}, | ||
buildGradleExtra = """ | ||
|class Speed implements Owner { | ||
| String toString() { return "Speed" } | ||
|} | ||
|class Performance implements Owner { | ||
| String toString() { return "Performance" } | ||
|} | ||
|def speed = new Speed() { } | ||
|def performance = new Performance() { } | ||
| | ||
|ownership { | ||
| owners = [speed, performance] | ||
|} | ||
""".trimMargin() | ||
), | ||
KotlinModule(name = "common") | ||
) | ||
).generateIn(projectDir) | ||
|
||
gradlew( | ||
projectDir, | ||
"exportCodeOwnershipInfo", | ||
).assertThat().buildSuccessful() | ||
|
||
val file = File(projectDir, "ownership.csv") | ||
assertTrue(file.exists()) | ||
|
||
assertEquals(""" | ||
|:app,"Speed" | ||
|:common,"" | ||
|:feature,"Speed,Performance" | ||
| | ||
""".trimMargin(), file.readText()) | ||
} | ||
} |
Oops, something went wrong.