Skip to content

Commit

Permalink
set environment var
Browse files Browse the repository at this point in the history
  • Loading branch information
diosmosis committed Feb 29, 2024
1 parent a721fe0 commit 1d2ea4c
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 38 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ jobs:

- name: Test
run: npm test
env:
USE_LOCALTUNNEL: ${{ secrets.USE_LOCALTUNNEL }}

- name: Archive test artifacts (actual)
uses: actions/upload-artifact@v3
Expand Down
79 changes: 41 additions & 38 deletions tests/appscript/config.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,52 +70,55 @@ describe('config', () => {
expect(result).toEqual(getExpectedResponse(result, 'config', 'step2'));
});

if (process.env.USE_LOCALTUNNEL) {
describe('#localtunnel tests', () => {
let server: ReturnType<typeof makeMatomo4MockServer>;
let tunnel;

if (process.env.USE_LOCALTUNNEL) {
beforeAll(async () => {
// create localtunnel
tunnel = await localtunnel({
port: 3000,
host: process.env.USE_LOCALTUNNEL,
});
describe('#localtunnel tests', () => {
let server: ReturnType<typeof makeMatomo4MockServer>;
let tunnel;

if (process.env.USE_LOCALTUNNEL) {
beforeAll(async () => {
// create localtunnel
tunnel = await localtunnel({
port: 3000,
host: process.env.USE_LOCALTUNNEL,
});
});

afterEach(async () => {
if (server) {
await new Promise((r) => {
server.close(r);
});
server = null;
}
});
afterEach(async () => {
if (server) {
await new Promise((r) => {
server.close(r);
});
server = null;
}
});

afterAll(async () => {
await tunnel.close();
});
afterAll(async () => {
await tunnel.close();
});
}

it('should return the expected response when the Matomo version is < 4.14', async () => {
if (!process.env.USE_LOCALTUNNEL) {
console.log('*** SKIPPING TEST ***');
return;
}

it('should return the expected response when the Matomo version is < 4.14', async () => {
server = makeMatomo4MockServer(3000);
server = makeMatomo4MockServer(3000);

// use the mock server's path that forces a non-random error
const setCredentialsResult = await Clasp.run('setCredentials', {
userToken: {
username: tunnel.url,
token: 'ignored',
},
});
// use the mock server's path that forces a non-random error
const setCredentialsResult = await Clasp.run('setCredentials', {
userToken: {
username: tunnel.url,
token: 'ignored',
},
});

expect(setCredentialsResult).toEqual({ errorCode: 'NONE' });
expect(setCredentialsResult).toEqual({ errorCode: 'NONE' });

let result = await Clasp.run('getConfig', {});
result = cleanUpSelects(result);
expect(result).toEqual(getExpectedResponse(result, 'config', 'oldMatomoVersion'));
});
let result = await Clasp.run('getConfig', {});
result = cleanUpSelects(result);
expect(result).toEqual(getExpectedResponse(result, 'config', 'oldMatomoVersion'));
});
}
});
});
});

0 comments on commit 1d2ea4c

Please sign in to comment.