-
-
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.
improve remote origin parsing tests (#6)
- Loading branch information
1 parent
380f63b
commit ba37f92
Showing
2 changed files
with
52 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,25 +5,68 @@ import io.kotest.matchers.shouldBe | |
import io.mockk.every | ||
import io.mockk.mockk | ||
import org.eclipse.jgit.api.Git | ||
import org.eclipse.jgit.lib.StoredConfig | ||
|
||
class GitConfigPropertiesProviderTest : StringSpec({ | ||
|
||
val storedConfig = mockk<StoredConfig>() { | ||
every { load() } returns Unit | ||
} | ||
val git = mockk<Git>() { | ||
every { repository.config } returns mockk(relaxed = true) { | ||
every { getString("user", null, "email") } returns "[email protected]" | ||
every { getString("user", null, "name") } returns "John Smith" | ||
every { getString("remote", "origin", "url") } returns "https://name:[email protected]/hndrs/gradle-git-properties-plugin.git" | ||
} | ||
every { repository.config } returns storedConfig | ||
} | ||
|
||
val underTest = GitConfigPropertiesProvider(git) | ||
|
||
"resolves git branch via git" { | ||
"resolves git config properties (remote origin with credentials)" { | ||
|
||
every { storedConfig.getString("user", null, "email") } returns "[email protected]" | ||
every { storedConfig.getString("user", null, "name") } returns "John Smith" | ||
every { storedConfig.getString("remote", "origin", "url") } returns "https://name:[email protected]/hndrs/gradle-git-properties-plugin.git" | ||
|
||
underTest.get() shouldBe mapOf( | ||
"git.build.user.email" to "[email protected]", | ||
"git.build.user.name" to "John Smith", | ||
"git.remote.origin.url" to "https://github.com/hndrs/gradle-git-properties-plugin.git" | ||
) | ||
} | ||
|
||
"resolves git config properties (remote with git/ssh )" { | ||
|
||
every { storedConfig.getString("user", null, "email") } returns "[email protected]" | ||
every { storedConfig.getString("user", null, "name") } returns "John Smith" | ||
every { storedConfig.getString("remote", "origin", "url") } returns "[email protected]/hndrs/gradle-git-properties-plugin.git" | ||
|
||
underTest.get() shouldBe mapOf( | ||
"git.build.user.email" to "[email protected]", | ||
"git.build.user.name" to "John Smith", | ||
"git.remote.origin.url" to "[email protected]/hndrs/gradle-git-properties-plugin.git" | ||
) | ||
} | ||
|
||
"resolves git config properties (with unrecognized data)" { | ||
|
||
every { storedConfig.getString("user", null, "email") } returns "[email protected]" | ||
every { storedConfig.getString("user", null, "name") } returns "John Smith" | ||
every { storedConfig.getString("remote", "origin", "url") } returns "someUnrelatedString" | ||
|
||
underTest.get() shouldBe mapOf( | ||
"git.build.user.email" to "[email protected]", | ||
"git.build.user.name" to "John Smith", | ||
"git.remote.origin.url" to "someUnrelatedString" | ||
) | ||
} | ||
|
||
"resolves git config properties (with exception on parsing data)" { | ||
|
||
every { storedConfig.getString("user", null, "email") } returns "[email protected]" | ||
every { storedConfig.getString("user", null, "name") } returns "John Smith" | ||
every { storedConfig.getString("remote", "origin", "url") } returns "https>" | ||
|
||
underTest.get() shouldBe mapOf( | ||
"git.build.user.email" to "[email protected]", | ||
"git.build.user.name" to "John Smith", | ||
"git.remote.origin.url" to null | ||
) | ||
} | ||
}) |