-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Converted tests to JUnit and upgraded Truth Version
- Loading branch information
1 parent
3b4897b
commit 20b02b4
Showing
5 changed files
with
151 additions
and
185 deletions.
There are no files selected for viewing
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
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
76 changes: 36 additions & 40 deletions
76
...s/owners-github-codeowners/src/test/kotlin/com/github/pgreze/kowners/CodeOwnershipTest.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 |
---|---|---|
@@ -1,56 +1,52 @@ | ||
package com.github.pgreze.kowners | ||
|
||
import org.spekframework.spek2.Spek | ||
import org.spekframework.spek2.style.specification.describe | ||
import org.junit.Test | ||
import kotlin.test.assertEquals | ||
import kotlin.test.assertFails | ||
import kotlin.test.assertNull | ||
|
||
class CodeOwnershipTest : Spek({ | ||
class CodeOwnershipTest { | ||
|
||
describe("Codeowners comment") { | ||
it("returns null") { | ||
assertNull("# A comment".parseCodeOwnersLine()) | ||
} | ||
@Test | ||
fun `Codeowners comment`() { | ||
assertNull("# A comment".parseCodeOwnersLine()) | ||
} | ||
|
||
describe("Empty Codeowners line") { | ||
it("returns null") { | ||
assertNull("".parseCodeOwnersLine()) | ||
} | ||
@Test | ||
fun `Empty Codeowners line`() { | ||
assertNull("".parseCodeOwnersLine()) | ||
} | ||
|
||
describe("Simple Codeowners line") { | ||
it("returns correct value for 1 owner") { | ||
val expected = CodeOwnership( | ||
pattern = Pattern("docs/"), | ||
owners = listOf("@me") | ||
) | ||
assertEquals(expected, "docs/ @me".parseCodeOwnersLine()) | ||
} | ||
|
||
it("returns correct value for multiple owners") { | ||
val expected = CodeOwnership( | ||
pattern = Pattern("docs/"), | ||
owners = listOf("@me", "@org/team-name") | ||
) | ||
assertEquals(expected, "docs/ @me @org/team-name".parseCodeOwnersLine()) | ||
} | ||
@Test | ||
fun `Simple Codeowners line - returns correct value for 1 owner`() { | ||
val expected = CodeOwnership( | ||
pattern = Pattern("docs/"), | ||
owners = listOf("@me") | ||
) | ||
assertEquals(expected, "docs/ @me".parseCodeOwnersLine()) | ||
} | ||
|
||
describe("Codeowners line with escaped space") { | ||
it("returns correct value") { | ||
val expected = CodeOwnership( | ||
pattern = Pattern("docs/\\ hello"), | ||
owners = listOf("@me") | ||
) | ||
assertEquals(expected, "docs/\\ hello @me".parseCodeOwnersLine()) | ||
} | ||
@Test | ||
fun `Simple Codeowners line - returns correct value for multiple owners`() { | ||
val expected = CodeOwnership( | ||
pattern = Pattern("docs/"), | ||
owners = listOf("@me", "@org/team-name") | ||
) | ||
assertEquals(expected, "docs/ @me @org/team-name".parseCodeOwnersLine()) | ||
} | ||
|
||
describe("Codeowners line with invalid owners") { | ||
it("returns correct message for no owner") { | ||
assertFails("No owner in line: docs/") { "docs/".parseCodeOwnersLine() } | ||
} | ||
@Test | ||
fun `Codeowners line with escaped space - returns correct value`() { | ||
val expected = CodeOwnership( | ||
pattern = Pattern("docs/\\ hello"), | ||
owners = listOf("@me") | ||
) | ||
assertEquals(expected, "docs/\\ hello @me".parseCodeOwnersLine()) | ||
} | ||
}) | ||
|
||
@Test | ||
fun `Codeowners line with invalid owners returns correct message for no owner`() { | ||
assertFails("No owner in line: docs/") { "docs/".parseCodeOwnersLine() } | ||
} | ||
|
||
} |
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
Oops, something went wrong.