Skip to content

Commit 0f09499

Browse files
authored
Publish API interface test fixture (#48)
Clients that test logic relying on library interfaces will create a fake implementation. Since the library itself does this, start publishing test fixtures with such code.
1 parent a8be876 commit 0f09499

File tree

3 files changed

+151
-113
lines changed

3 files changed

+151
-113
lines changed

build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ plugins {
77
id("org.jetbrains.dokka") version "1.8.10"
88
id("org.openapi.generator") version "6.5.0"
99
`java-library`
10+
`java-test-fixtures`
1011
`maven-publish`
1112
}
1213

src/test/kotlin/com/gabrielfeo/gradle/enterprise/api/FakeGradleEnterpriseApi.kt

Lines changed: 1 addition & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import kotlinx.coroutines.flow.MutableStateFlow
55

66
class FakeGradleEnterpriseApi(
77
val builds: List<Build>,
8-
) : GradleEnterpriseApi {
8+
) : FakeGradleEnterpriseApiScaffold {
99

1010
val getBuildsCallCount = MutableStateFlow(0)
1111
val getGradleAtrributesCallCount = MutableStateFlow(0)
@@ -47,116 +47,4 @@ class FakeGradleEnterpriseApi(
4747
val attrs = readFromJsonResource<GradleAttributes>("gradle-attributes-response.json")
4848
return attrs.copy(id = id)
4949
}
50-
51-
override suspend fun createOrUpdateBuildCacheNode(
52-
name: String,
53-
nodeConfiguration: NodeConfiguration,
54-
) {
55-
TODO("Not yet implemented")
56-
}
57-
58-
override suspend fun createOrUpdateTestDistributionAgentPool(
59-
poolId: String,
60-
testDistributionAgentPoolConfiguration: TestDistributionAgentPoolConfiguration,
61-
): TestDistributionAgentPoolConfigurationWithId {
62-
TODO("Not yet implemented")
63-
}
64-
65-
override suspend fun createTestDistributionAgentPool(testDistributionAgentPoolConfiguration: TestDistributionAgentPoolConfiguration): TestDistributionAgentPoolConfigurationWithId {
66-
TODO("Not yet implemented")
67-
}
68-
69-
override suspend fun deleteTestDistributionAgentPool(poolId: String) {
70-
TODO("Not yet implemented")
71-
}
72-
73-
override suspend fun generateTestDistributionApiKey(): TestDistributionApiKey {
74-
TODO("Not yet implemented")
75-
}
76-
77-
override suspend fun getBuild(id: String, availabilityWaitTimeoutSecs: Int?): Build {
78-
TODO("Not yet implemented")
79-
}
80-
81-
override suspend fun getBuildCacheNode(name: String): NodeConfiguration {
82-
TODO("Not yet implemented")
83-
}
84-
85-
override suspend fun getGradleBuildCachePerformance(
86-
id: String,
87-
availabilityWaitTimeoutSecs: Int?,
88-
): GradleBuildCachePerformance {
89-
TODO("Not yet implemented")
90-
}
91-
92-
override suspend fun getGradleProjects(
93-
id: String,
94-
availabilityWaitTimeoutSecs: Int?,
95-
): List<GradleProject> {
96-
TODO("Not yet implemented")
97-
}
98-
99-
override suspend fun getMavenAttributes(
100-
id: String,
101-
availabilityWaitTimeoutSecs: Int?,
102-
): MavenAttributes {
103-
TODO("Not yet implemented")
104-
}
105-
106-
override suspend fun getMavenBuildCachePerformance(
107-
id: String,
108-
availabilityWaitTimeoutSecs: Int?,
109-
): MavenBuildCachePerformance {
110-
TODO("Not yet implemented")
111-
}
112-
113-
override suspend fun getMavenModules(
114-
id: String,
115-
availabilityWaitTimeoutSecs: Int?,
116-
): List<MavenModule> {
117-
TODO("Not yet implemented")
118-
}
119-
120-
override suspend fun getTestDistributionAgentPool(poolId: String): TestDistributionAgentPoolConfigurationWithId {
121-
TODO("Not yet implemented")
122-
}
123-
124-
override suspend fun getTestDistributionAgentPoolStatus(poolId: String): TestDistributionAgentPoolStatus {
125-
TODO("Not yet implemented")
126-
}
127-
128-
override suspend fun getTestDistributionApiKey(keyPrefix: String): TestDistributionApiKeyPrefix {
129-
TODO("Not yet implemented")
130-
}
131-
132-
override suspend fun getVersion(): GradleEnterpriseVersion {
133-
TODO("Not yet implemented")
134-
}
135-
136-
override suspend fun initiatePurgeOfBuildCacheNode(name: String) {
137-
TODO("Not yet implemented")
138-
}
139-
140-
override suspend fun insertTestDistributionApiKey(
141-
keyPrefix: String,
142-
testDistributionApiKey: TestDistributionApiKey,
143-
): TestDistributionApiKeyPrefix {
144-
TODO("Not yet implemented")
145-
}
146-
147-
override suspend fun listTestDistributionAgentPools(): TestDistributionAgentPoolPage {
148-
TODO("Not yet implemented")
149-
}
150-
151-
override suspend fun listTestDistributionApiKeys(): TestDistributionApiKeyPrefixPage {
152-
TODO("Not yet implemented")
153-
}
154-
155-
override suspend fun regenerateSecretOfBuildCacheNode(name: String): KeySecretPair {
156-
TODO("Not yet implemented")
157-
}
158-
159-
override suspend fun revokeTestDistributionApiKey(keyPrefix: String) {
160-
TODO("Not yet implemented")
161-
}
16250
}
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
package com.gabrielfeo.gradle.enterprise.api
2+
3+
import com.gabrielfeo.gradle.enterprise.api.model.*
4+
5+
/**
6+
* Scaffold for a fake `GradleEnterpriseApi` implementation with default methods throwing a
7+
* [NotImplementedError]. Extend this interface and override methods to fake behavior as needed.
8+
*/
9+
interface FakeGradleEnterpriseApiScaffold : GradleEnterpriseApi {
10+
11+
override suspend fun createOrUpdateBuildCacheNode(
12+
name: String,
13+
nodeConfiguration: NodeConfiguration,
14+
) {
15+
TODO("Not yet implemented")
16+
}
17+
18+
override suspend fun createOrUpdateTestDistributionAgentPool(
19+
poolId: String,
20+
testDistributionAgentPoolConfiguration: TestDistributionAgentPoolConfiguration,
21+
): TestDistributionAgentPoolConfigurationWithId {
22+
TODO("Not yet implemented")
23+
}
24+
25+
override suspend fun createTestDistributionAgentPool(
26+
testDistributionAgentPoolConfiguration: TestDistributionAgentPoolConfiguration,
27+
): TestDistributionAgentPoolConfigurationWithId {
28+
TODO("Not yet implemented")
29+
}
30+
31+
override suspend fun deleteTestDistributionAgentPool(poolId: String) {
32+
TODO("Not yet implemented")
33+
}
34+
35+
override suspend fun generateTestDistributionApiKey(): TestDistributionApiKey {
36+
TODO("Not yet implemented")
37+
}
38+
39+
override suspend fun getBuild(id: String, availabilityWaitTimeoutSecs: Int?): Build {
40+
TODO("Not yet implemented")
41+
}
42+
43+
override suspend fun getBuildCacheNode(name: String): NodeConfiguration {
44+
TODO("Not yet implemented")
45+
}
46+
47+
override suspend fun getBuilds(
48+
since: Long?,
49+
sinceBuild: String?,
50+
fromInstant: Long?,
51+
fromBuild: String?,
52+
reverse: Boolean?,
53+
maxBuilds: Int?,
54+
maxWaitSecs: Int?,
55+
): List<Build> {
56+
TODO("Not yet implemented")
57+
}
58+
59+
override suspend fun getGradleAttributes(
60+
id: String,
61+
availabilityWaitTimeoutSecs: Int?,
62+
): GradleAttributes {
63+
TODO("Not yet implemented")
64+
}
65+
66+
override suspend fun getGradleBuildCachePerformance(
67+
id: String,
68+
availabilityWaitTimeoutSecs: Int?,
69+
): GradleBuildCachePerformance {
70+
TODO("Not yet implemented")
71+
}
72+
73+
override suspend fun getGradleProjects(
74+
id: String,
75+
availabilityWaitTimeoutSecs: Int?,
76+
): List<GradleProject> {
77+
TODO("Not yet implemented")
78+
}
79+
80+
override suspend fun getMavenAttributes(
81+
id: String,
82+
availabilityWaitTimeoutSecs: Int?,
83+
): MavenAttributes {
84+
TODO("Not yet implemented")
85+
}
86+
87+
override suspend fun getMavenBuildCachePerformance(
88+
id: String,
89+
availabilityWaitTimeoutSecs: Int?,
90+
): MavenBuildCachePerformance {
91+
TODO("Not yet implemented")
92+
}
93+
94+
override suspend fun getMavenModules(
95+
id: String,
96+
availabilityWaitTimeoutSecs: Int?,
97+
): List<MavenModule> {
98+
TODO("Not yet implemented")
99+
}
100+
101+
override suspend fun getTestDistributionAgentPool(
102+
poolId: String,
103+
): TestDistributionAgentPoolConfigurationWithId {
104+
TODO("Not yet implemented")
105+
}
106+
107+
override suspend fun getTestDistributionAgentPoolStatus(
108+
poolId: String,
109+
): TestDistributionAgentPoolStatus {
110+
TODO("Not yet implemented")
111+
}
112+
113+
override suspend fun getTestDistributionApiKey(
114+
keyPrefix: String,
115+
): TestDistributionApiKeyPrefix {
116+
TODO("Not yet implemented")
117+
}
118+
119+
override suspend fun getVersion(): GradleEnterpriseVersion {
120+
TODO("Not yet implemented")
121+
}
122+
123+
override suspend fun initiatePurgeOfBuildCacheNode(name: String) {
124+
TODO("Not yet implemented")
125+
}
126+
127+
override suspend fun insertTestDistributionApiKey(
128+
keyPrefix: String,
129+
testDistributionApiKey: TestDistributionApiKey,
130+
): TestDistributionApiKeyPrefix {
131+
TODO("Not yet implemented")
132+
}
133+
134+
override suspend fun listTestDistributionAgentPools(): TestDistributionAgentPoolPage {
135+
TODO("Not yet implemented")
136+
}
137+
138+
override suspend fun listTestDistributionApiKeys(): TestDistributionApiKeyPrefixPage {
139+
TODO("Not yet implemented")
140+
}
141+
142+
override suspend fun regenerateSecretOfBuildCacheNode(name: String): KeySecretPair {
143+
TODO("Not yet implemented")
144+
}
145+
146+
override suspend fun revokeTestDistributionApiKey(keyPrefix: String) {
147+
TODO("Not yet implemented")
148+
}
149+
}

0 commit comments

Comments
 (0)