diff --git a/lib/models/config.ts b/lib/models/config.ts index 108a35f..c99e5b3 100644 --- a/lib/models/config.ts +++ b/lib/models/config.ts @@ -7,7 +7,7 @@ export enum Platform { GITEA = "gitea", GITHUB = "github", GITLAB = "gitlab", - NULL = "", + NULL = "null", } /** diff --git a/lib/verify-config.ts b/lib/verify-config.ts index 6f2cbea..094c4d6 100644 --- a/lib/verify-config.ts +++ b/lib/verify-config.ts @@ -32,12 +32,12 @@ const validTargetsArray = (targets: Partial[]): boolean => targets. /** * validPlatform validates an input string platform. * - * @param stringPlatform the platform to validate. + * @param input the platform to validate. * * @returns true if the input platform is valid. */ -const validPlatform = (stringPlatform: string): boolean => Boolean(Object.values(Platform). - find(platform => platform.toString() === stringPlatform)) +const validPlatform = (input: Platform): boolean => Boolean(Object.values(Platform). + find(platform => input === platform)) /** * ensureDefaults takes as input a partial backmerge configuration, alongside environment variables @@ -73,7 +73,7 @@ export const verifyConfig = (config: BackmergeConfig): void => { commit: [isString, stringNotEmpty], debug: [isBoolean], // shouldn't happen since it comes from semantic-release config dryRun: [isBoolean], // shouldn't happen since it comes from semantic-release config - platform: [isString, validPlatform], + platform: [validPlatform], repositoryUrl: [isString, stringNotEmpty], // shouldn't happen since it comes from semantic-release config targets: [isArray, validTargetsArray], title: [isString, stringNotEmpty], diff --git a/test/verify-config.test.ts b/test/verify-config.test.ts index 7a14bf3..090d58d 100644 --- a/test/verify-config.test.ts +++ b/test/verify-config.test.ts @@ -186,20 +186,18 @@ describe("verifyConfig", () => { matcher.toThrowError(getConfigError("targets", targets).message) }) - test("should throw an invalid platform with base url", () => { + test("should be fine with minimal inputs", () => { // Arrange - const config = ensureDefault({ - baseUrl: "https://example.com", - }, { GITHUB_TOKEN: "some token" }) + const config = ensureDefault({ repositoryUrl: "some repository url" }, { GITHUB_TOKEN: "some token" }) // Act const matcher = expect(() => verifyConfig(config)) // Assert - matcher.toThrowError(getConfigError("platform", "").message) + matcher.not.toThrowError() }) - test("should be fine with base url", () => { + test("should be fine with some inputs", () => { // Arrange const config = ensureDefault({ baseUrl: "https://example.com",