Skip to content

Commit 5aa2d21

Browse files
committed
feat: speakeasy configure tests
1 parent 7c18152 commit 5aa2d21

File tree

687 files changed

+173761
-4
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

687 files changed

+173761
-4
lines changed

.github/workflows/sdk_test.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Test
2+
permissions:
3+
checks: write
4+
contents: write
5+
pull-requests: write
6+
statuses: write
7+
id-token: write
8+
"on":
9+
pull_request:
10+
branches:
11+
- main
12+
paths:
13+
- '**'
14+
workflow_dispatch:
15+
inputs:
16+
target:
17+
description: Provided SDK target to run tests for, (all) is valid
18+
type: string
19+
jobs:
20+
test:
21+
uses: speakeasy-api/sdk-generation-action/.github/workflows/sdk-test.yaml@v15
22+
with:
23+
target: ${{ github.event.inputs.target || 'glean' }}
24+
secrets:
25+
github_access_token: ${{ secrets.GITHUB_TOKEN }}
26+
speakeasy_api_key: ${{ secrets.SPEAKEASY_API_KEY }}

.speakeasy/gen.lock

Lines changed: 823 additions & 2 deletions
Large diffs are not rendered by default.

.speakeasy/gen.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ generation:
1616
auth:
1717
oAuth2ClientCredentialsEnabled: true
1818
oAuth2PasswordEnabled: true
19+
tests:
20+
generateNewTests: true
21+
skipResponseBodyAssertions: false
1922
java:
2023
version: 0.5.4
2124
additionalDependencies: []

.speakeasy/testfiles/example.file

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
hello world

.speakeasy/tests.arazzo.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164257,3 +164257,38 @@ workflows:
164257164257
{}
164258164258
type: simple
164259164259
x-speakeasy-test-group: policies
164260+
- workflowId: uploadchatfiles
164261+
steps:
164262+
- stepId: test
164263+
operationId: uploadchatfiles
164264+
requestBody:
164265+
contentType: multipart/form-data
164266+
payload:
164267+
files:
164268+
- 'x-file: example.file'
164269+
successCriteria:
164270+
- condition: $statusCode == 200
164271+
- condition: $response.header.Content-Type == application/json
164272+
- context: $response.body
164273+
condition: |
164274+
{
164275+
"files": [
164276+
{
164277+
"id": "FILE_1234",
164278+
"url": "www.google.com",
164279+
"name": "sample.pdf"
164280+
},
164281+
{
164282+
"id": "FILE_1234",
164283+
"url": "www.google.com",
164284+
"name": "sample.pdf"
164285+
},
164286+
{
164287+
"id": "FILE_1234",
164288+
"url": "www.google.com",
164289+
"name": "sample.pdf"
164290+
}
164291+
]
164292+
}
164293+
type: simple
164294+
x-speakeasy-test-group: chat

.speakeasy/workflow.lock

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ sources:
66
sourceBlobDigest: sha256:f2a59d8beefedbda0e59b25d09a930e1b907145f784bf8961fc31b862163d964
77
tags:
88
- latest
9-
- speakeasy-sdk-regen-1749454026
109
Glean-OAS:
1110
sourceNamespace: glean-oas
1211
sourceRevisionDigest: sha256:8841834dd58ddd4e2dcf98fc90fbd06fbf3626a29df941503cce55b9548a5317
@@ -21,7 +20,7 @@ targets:
2120
sourceRevisionDigest: sha256:254ed74184de2e725a0dc2cf521b132b29ece9d3ba6b12fd7e7b1ceaa2e6d043
2221
sourceBlobDigest: sha256:f2a59d8beefedbda0e59b25d09a930e1b907145f784bf8961fc31b862163d964
2322
codeSamplesNamespace: glean-api-specs-java-code-samples
24-
codeSamplesRevisionDigest: sha256:e6b8f88064c039aa8020b1618efbbbcd8ffb72cbc6122b8a74e3879b4545606e
23+
codeSamplesRevisionDigest: sha256:e5b2ea5208c1dc6e24e3a32186332fee5e6235cc612e785611add744c44901fa
2524
workflow:
2625
workflowVersion: 1.0.0
2726
speakeasyVersion: latest
@@ -46,3 +45,5 @@ workflow:
4645
labelOverride:
4746
fixedValue: Java (API Client)
4847
blocking: false
48+
testing:
49+
enabled: true

.speakeasy/workflow.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,5 @@ targets:
2121
labelOverride:
2222
fixedValue: Java (API Client)
2323
blocking: false
24+
testing:
25+
enabled: true

build.gradle

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ plugins {
1515
id 'maven-publish'
1616
id 'signing'
1717
id 'cl.franciscosolis.sonatype-central-upload' version '1.0.3'
18+
id "com.adarshr.test-logger" version "3.2.0"
1819
}
1920

2021
compileJava.options.encoding = "UTF-8"
@@ -147,6 +148,45 @@ if (!project.hasProperty('skip.signing')) {
147148
}
148149

149150

151+
tasks.named('test') {
152+
// Use JUnit Platform for unit tests.
153+
useJUnitPlatform()
154+
}
155+
156+
testlogger {
157+
showStandardStreams true
158+
}
159+
160+
test {
161+
maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1
162+
finalizedBy 'mergeJUnitReports'
163+
}
164+
165+
configurations {
166+
antJUnit
167+
}
168+
169+
task mergeJUnitReports {
170+
ext {
171+
resultsDir = file("$buildDir/test-results/test")
172+
targetDir = file(".speakeasy/reports")
173+
}
174+
175+
doLast {
176+
ant.taskdef(
177+
name: 'junitreport',
178+
classname: 'org.apache.tools.ant.taskdefs.optional.junit.XMLResultAggregator',
179+
classpath: configurations.antJUnit.asPath
180+
)
181+
182+
mkdir targetDir
183+
184+
ant.junitreport(todir: targetDir, tofile: 'tests.xml') {
185+
fileset(dir: resultsDir, includes: 'TEST-*.xml')
186+
}
187+
}
188+
}
189+
150190

151191
dependencies {
152192
api 'com.fasterxml.jackson.core:jackson-annotations:2.18.2'
@@ -155,6 +195,10 @@ dependencies {
155195
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.18.2'
156196
api('org.openapitools:jackson-databind-nullable:0.2.6') {exclude group: 'com.fasterxml.jackson.core', module: 'jackson-databind'}
157197
implementation 'commons-io:commons-io:2.18.0'
198+
testImplementation 'org.junit.jupiter:junit-jupiter:5.11.4'
199+
testImplementation 'org.mockito:mockito-core:5.14.2'
200+
testRuntimeOnly 'org.junit.platform:junit-platform-launcher:1.11.4'
201+
antJUnit 'org.apache.ant:ant-junit:1.9.7'
158202
}
159203

160204
apply from: 'build-extras.gradle'
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3+
*/
4+
package com.glean.api_client.glean_api_client;
5+
6+
import static org.junit.jupiter.api.Assertions.assertEquals;
7+
8+
import com.glean.api_client.glean_api_client.models.components.Event;
9+
import com.glean.api_client.glean_api_client.models.components.Feedback;
10+
import com.glean.api_client.glean_api_client.models.operations.FeedbackResponse;
11+
import com.glean.api_client.glean_api_client.utils.Utils;
12+
import java.lang.Exception;
13+
import java.util.List;
14+
import org.junit.jupiter.api.Test;
15+
16+
public class ActivitiesTests {
17+
18+
@Test
19+
public void testActivities_Feedback() throws Exception {
20+
21+
var testHttpClient = Utils.createTestHTTPClient("feedback");
22+
Glean sdk = Glean.builder()
23+
.serverURL(Utils.environmentVariable("TEST_SERVER_URL", "http://localhost:18080"))
24+
.client(testHttpClient)
25+
.apiToken("<YOUR_BEARER_TOKEN_HERE>")
26+
.build();
27+
28+
FeedbackResponse res = sdk.client().activity().feedback()
29+
.feedback1(Feedback.builder()
30+
.trackingTokens(List.of(
31+
"trackingTokens"))
32+
.event(Event.VIEW)
33+
.build())
34+
.call();
35+
assertEquals(200, res.statusCode());
36+
}
37+
}
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
/*
2+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3+
*/
4+
package com.glean.api_client.glean_api_client;
5+
6+
import static org.junit.jupiter.api.Assertions.assertEquals;
7+
8+
import com.glean.api_client.glean_api_client.models.components.Agent;
9+
import com.glean.api_client.glean_api_client.models.components.AgentCapabilities;
10+
import com.glean.api_client.glean_api_client.models.components.AgentSchemas;
11+
import com.glean.api_client.glean_api_client.models.components.InputSchema;
12+
import com.glean.api_client.glean_api_client.models.components.OutputSchema;
13+
import com.glean.api_client.glean_api_client.models.operations.GetAgentResponse;
14+
import com.glean.api_client.glean_api_client.models.operations.GetAgentSchemasResponse;
15+
import com.glean.api_client.glean_api_client.utils.Utils;
16+
import java.lang.Exception;
17+
import org.junit.jupiter.api.Assumptions;
18+
import org.junit.jupiter.api.Test;
19+
20+
public class AgentsTests {
21+
22+
@Test
23+
public void testAgents_Runagent() throws Exception {
24+
Assumptions.assumeTrue(false, "incomplete test found please make sure to address the following errors: [`workflow step runagent.test referencing operation runagent not found in document`]");
25+
}
26+
27+
@Test
28+
public void testAgents_Listagents() throws Exception {
29+
Assumptions.assumeTrue(false, "incomplete test found please make sure to address the following errors: [`workflow step listagents.test referencing operation listagents not found in document`]");
30+
}
31+
32+
@Test
33+
public void testAgents_Getagentinputs() throws Exception {
34+
Assumptions.assumeTrue(false, "incomplete test found please make sure to address the following errors: [`workflow step getagentinputs.test referencing operation getagentinputs not found in document`]");
35+
}
36+
37+
@Test
38+
public void testAgents_GetAgent() throws Exception {
39+
40+
var testHttpClient = Utils.createTestHTTPClient("getAgent");
41+
Glean sdk = Glean.builder()
42+
.serverURL(Utils.environmentVariable("TEST_SERVER_URL", "http://localhost:18080"))
43+
.client(testHttpClient)
44+
.apiToken("<YOUR_BEARER_TOKEN_HERE>")
45+
.build();
46+
47+
GetAgentResponse res = sdk.client().agents().retrieve()
48+
.agentId("<id>")
49+
.call();
50+
assertEquals(200, res.statusCode());
51+
assertEquals(
52+
Agent.builder()
53+
.agentId("<id>")
54+
.name("<value>")
55+
.capabilities(AgentCapabilities.builder()
56+
.build())
57+
.build(),
58+
res.agent().get());
59+
}
60+
61+
@Test
62+
public void testAgents_GetAgentSchemas() throws Exception {
63+
64+
var testHttpClient = Utils.createTestHTTPClient("getAgentSchemas");
65+
Glean sdk = Glean.builder()
66+
.serverURL(Utils.environmentVariable("TEST_SERVER_URL", "http://localhost:18080"))
67+
.client(testHttpClient)
68+
.apiToken("<YOUR_BEARER_TOKEN_HERE>")
69+
.build();
70+
71+
GetAgentSchemasResponse res = sdk.client().agents().retrieveSchemas()
72+
.agentId("<id>")
73+
.call();
74+
assertEquals(200, res.statusCode());
75+
assertEquals(
76+
AgentSchemas.builder()
77+
.agentId("<id>")
78+
.inputSchema(InputSchema.builder()
79+
.build())
80+
.outputSchema(OutputSchema.builder()
81+
.build())
82+
.build(),
83+
res.agentSchemas().get());
84+
}
85+
86+
@Test
87+
public void testAgents_SearchAgents() throws Exception {
88+
Assumptions.assumeTrue(false, "incomplete test found please make sure to address the following errors: [`workflow step searchAgents.test referencing operation searchAgents is missing required request body`]");
89+
}
90+
91+
@Test
92+
public void testAgents_CreateAndStreamRun() throws Exception {
93+
Assumptions.assumeTrue(false, "incomplete test found please make sure to address the following errors: [`workflow step createAndStreamRun.test referencing operation createAndStreamRun is not currently supported`]");
94+
}
95+
96+
@Test
97+
public void testAgents_CreateAndWaitRun() throws Exception {
98+
Assumptions.assumeTrue(false, "incomplete test found please make sure to address the following errors: [`workflow step createAndWaitRun.test referencing operation createAndWaitRun is missing required request body`]");
99+
}
100+
}

0 commit comments

Comments
 (0)