mirror of
https://code.forgejo.org/docker/actions-toolkit.git
synced 2025-06-28 08:35:36 -04:00
test: githubActionsRuntimeToken
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
parent
85ef93202e
commit
039779492c
3 changed files with 32 additions and 3 deletions
|
@ -1,4 +1,6 @@
|
|||
import {describe, expect, jest, it, beforeEach, afterEach} from '@jest/globals';
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
|
||||
import {GitHub, GitHubRepo} from '../src/github';
|
||||
|
||||
|
@ -45,6 +47,31 @@ describe('serverURL', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('actionsRuntimeToken', () => {
|
||||
const originalEnv = process.env;
|
||||
beforeEach(() => {
|
||||
jest.resetModules();
|
||||
process.env = {
|
||||
...originalEnv
|
||||
};
|
||||
});
|
||||
afterEach(() => {
|
||||
process.env = originalEnv;
|
||||
});
|
||||
it('empty', async () => {
|
||||
process.env.ACTIONS_RUNTIME_TOKEN = '';
|
||||
const github = new GitHub();
|
||||
expect(github.actionsRuntimeToken).toEqual({});
|
||||
});
|
||||
it('fixture', async () => {
|
||||
process.env.ACTIONS_RUNTIME_TOKEN = fs.readFileSync(path.join(__dirname, 'fixtures', 'runtimeToken.txt')).toString().trim();
|
||||
const github = new GitHub();
|
||||
const runtimeToken = github.actionsRuntimeToken;
|
||||
expect(runtimeToken.ac).toEqual('[{"Scope":"refs/heads/master","Permission":3}]');
|
||||
expect(runtimeToken.iss).toEqual('vstoken.actions.githubusercontent.com');
|
||||
});
|
||||
});
|
||||
|
||||
describe('repoData', () => {
|
||||
it('returns GitHub repository', async () => {
|
||||
const github = new GitHub();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue