blob: f3171a571a1ff314ddb979344e202be66cd5d35a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
package org.jetbrains.dokka.dokkatoo.dokka.parameters
import io.kotest.core.spec.style.FunSpec
import io.kotest.engine.spec.tempdir
import io.kotest.matchers.shouldBe
import org.gradle.api.Project
import org.gradle.api.provider.Provider
import org.gradle.kotlin.dsl.*
import org.gradle.testfixtures.ProjectBuilder
class DokkaSourceLinkSpecTest : FunSpec({
val project = ProjectBuilder.builder().build()
context("expect localDirectoryPath") {
test("is the invariantSeparatorsPath of localDirectory") {
val tempDir = tempdir()
val actual = project.createDokkaSourceLinkSpec {
localDirectory.set(tempDir)
}
actual.localDirectoryPath2.get() shouldBe tempDir.invariantSeparatorsPath
}
}
context("expect remoteUrl can be set") {
test("using a string") {
val actual = project.createDokkaSourceLinkSpec {
remoteUrl("https://github.com/adamko-dev/dokkatoo/")
}
actual.remoteUrl.get().toString() shouldBe "https://github.com/adamko-dev/dokkatoo/"
}
test("using a string-provider") {
val actual = project.createDokkaSourceLinkSpec {
remoteUrl(project.provider { "https://github.com/adamko-dev/dokkatoo/" })
}
actual.remoteUrl.get().toString() shouldBe "https://github.com/adamko-dev/dokkatoo/"
}
}
}) {
/** Re-implement [DokkaSourceLinkSpec] to make [localDirectoryPath] accessible in tests */
abstract class DokkaSourceLinkSpec2 : DokkaSourceLinkSpec() {
val localDirectoryPath2: Provider<String>
get() = super.localDirectoryPath
}
companion object {
private fun Project.createDokkaSourceLinkSpec(
configure: DokkaSourceLinkSpec.() -> Unit
): DokkaSourceLinkSpec2 =
objects.newInstance(DokkaSourceLinkSpec2::class).apply(configure)
}
}
|