Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 60 additions & 12 deletions generators/go-v2/sdk/src/wire-tests/WireTestGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -611,26 +611,74 @@ export class WireTestGenerator {
endpoint: FernIr.HttpEndpoint;
snippet: string;
}): go.CodeBlock {
// Generate the client constructor directly with WireMockBaseURL instead of parsing from snippet
// The snippet uses the original constructor args (e.g., WithToken), but we need WithBaseURL
// Generate the client constructor with WireMockBaseURL and auth options matching the WireMock matchers.
return go.codeblock((writer) => {
writer.write("client := ");
const arguments_: go.AstNode[] = [
go.invokeFunc({
func: go.typeReference({
name: "WithBaseURL",
importPath: this.context.getOptionImportPath()
}),
arguments_: [go.codeblock("WireMockBaseURL")],
multiline: false
})
];
// Add auth options when the endpoint requires authentication, so that the
// request matches the WireMock stub's header matchers.
if (endpoint.auth) {
for (const scheme of this.context.ir.auth.schemes) {
switch (scheme.type) {
case "bearer":
arguments_.push(
go.invokeFunc({
func: go.typeReference({
name: "WithToken",
importPath: this.context.getOptionImportPath()
}),
arguments_: [go.codeblock('"test-token"')],
multiline: false
})
);
break;
case "basic":
arguments_.push(
go.invokeFunc({
func: go.typeReference({
name: "WithBasicAuth",
importPath: this.context.getOptionImportPath()
}),
arguments_: [go.codeblock('"test-username"'), go.codeblock('"test-password"')],
multiline: false
})
);
break;
case "header": {
const fieldName = scheme.name?.name?.pascalCase?.unsafeName;
if (fieldName) {
arguments_.push(
go.invokeFunc({
func: go.typeReference({
name: `With${fieldName}`,
importPath: this.context.getOptionImportPath()
}),
arguments_: [go.codeblock('"test-value"')],
multiline: false
})
);
}
break;
}
}
}
}
writer.writeNode(
go.invokeFunc({
func: go.typeReference({
name: this.context.getClientConstructorName(),
importPath: this.context.getRootClientImportPath()
}),
arguments_: [
go.invokeFunc({
func: go.typeReference({
name: "WithBaseURL",
importPath: this.context.getOptionImportPath()
}),
arguments_: [go.codeblock("WireMockBaseURL")],
multiline: false
})
],
arguments_,
multiline: true
})
);
Expand Down
10 changes: 10 additions & 0 deletions generators/go/sdk/versions.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
# yaml-language-server: $schema=../../../fern-versions-yml.schema.json
- version: 1.33.4
changelogEntry:
- summary: |
Fix wire test client construction to include auth options (e.g.
WithToken) when the endpoint requires authentication, so that
requests match WireMock stub header matchers.
type: fix
createdAt: "2026-04-08"
irVersion: 61

- version: 1.33.3
changelogEntry:
- summary: |
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading