Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
bzp2010 committed Sep 15, 2024
1 parent 5a684cd commit ce39fac
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
16 changes: 13 additions & 3 deletions libs/backend-api7/e2e/support/global-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import axios from 'axios';
import { spawn } from 'node:child_process';
import { randomUUID } from 'node:crypto';
import { Agent } from 'node:https';
import { gte, lt } from 'semver';
import * as semver from 'semver';

const httpClient = axios.create({
baseURL: 'https://localhost:7443',
Expand Down Expand Up @@ -68,7 +68,12 @@ const initUser = async (username = 'admin', password = 'admin') => {
});

// If the version is lower than 3.2.15, the license should be activated first.
if (lt('3.2.15', process.env.BACKEND_API7_VERSION ?? '0.0.0'))
if (
semver.lt(
'3.2.15',
semver.coerce(process.env.BACKEND_API7_VERSION) ?? '0.0.0',
)
)
await activateAPI7();

console.log('Modify password');
Expand All @@ -88,7 +93,12 @@ const initUser = async (username = 'admin', password = 'admin') => {

// If the version is greater than or equal to 3.2.15, the license should
// be activated after changing the password.
if (gte('3.2.15', process.env.BACKEND_API7_VERSION ?? '0.0.0'))
if (
semver.gte(
'3.2.15',
semver.coerce(process.env.BACKEND_API7_VERSION) ?? '0.0.0',
)
)
await activateAPI7();
};

Expand Down
5 changes: 3 additions & 2 deletions libs/backend-api7/e2e/support/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as ADCSDK from '@api7/adc-sdk';
import { Listr, SilentRenderer } from 'listr2';
import * as semver from 'semver';

import { BackendAPI7 } from '../../src';

Expand Down Expand Up @@ -101,7 +102,7 @@ export const conditionalDescribe = (cond: cond) =>
export const conditionalIt = (cond: cond) => (cond ? it : it.skip);

export const semverCondition = (
op: (v1: string, v2: string) => boolean,
op: (v1: string, v2: string | semver.SemVer) => boolean,
target: string,
base = process.env.BACKEND_API7_VERSION ?? '0.0.0',
base = semver.coerce(process.env.BACKEND_API7_VERSION) ?? '0.0.0',
) => op(target, base);

0 comments on commit ce39fac

Please sign in to comment.