Skip to content

Commit

Permalink
fix(provider-generator): escape hyphens in provider names for Go pack…
Browse files Browse the repository at this point in the history
…age identifiers

resolves #1250
  • Loading branch information
ansgarm committed Nov 4, 2021
1 parent 3058eb7 commit 4b6c9bc
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import * as fs from "fs-extra";
import * as os from "os";
import * as path from "path";
import { determineGoModuleName } from "../constructs-maker";
import {
ConstructsMakerProviderTarget,
determineGoModuleName,
Language,
} from "../constructs-maker";

describe("constructsMaker", () => {
describe("determineGoModuleName", () => {
Expand Down Expand Up @@ -79,4 +83,18 @@ describe("constructsMaker", () => {
);
});
});
describe("ConstructsMakerProviderTarget", () => {
it("returns valid package name for Go", () => {
const target = new ConstructsMakerProviderTarget(
{
name: "google-beta",
fqn: "google-beta",
source: "google-beta",
version: "~> 4.0",
},
Language.GO
);
expect(target.srcMakName).toEqual("google_beta");
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export class ConstructsMakerProviderTarget extends ConstructsMakerTarget {
case Language.PYTHON:
return this.simplifiedName;
case Language.GO:
return this.name;
return this.name.replace(/-/gi, "_");
default:
return this.constraint.fqn;
}
Expand Down

0 comments on commit 4b6c9bc

Please sign in to comment.