Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
dependabot-action/__tests__/image-service.test.ts
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
49 lines (42 sloc)
1.16 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {ImageService} from '../src/image-service' | |
describe('ImageService', () => { | |
const originalEnv = process.env | |
describe('when GITHUB_TOKEN is not set', () => { | |
beforeEach(async () => { | |
jest.resetModules() | |
process.env = { | |
...originalEnv, | |
GITHUB_TOKEN: undefined | |
} | |
}) | |
afterEach(async () => { | |
process.env = originalEnv | |
}) | |
test('it raises an error', async () => { | |
await expect( | |
ImageService.pull('ghcr.io/dependabot/dependabot-core:latest') | |
).rejects.toThrowError( | |
new Error('No GITHUB_TOKEN set, unable to pull images.') | |
) | |
}) | |
}) | |
describe('when asked to fetch non-GitHub hosted images', () => { | |
beforeEach(async () => { | |
jest.resetModules() | |
process.env = { | |
...originalEnv, | |
GITHUB_TOKEN: 'mock_token' | |
} | |
}) | |
afterEach(async () => { | |
process.env = originalEnv | |
}) | |
test('it raises an error', async () => { | |
await expect(ImageService.pull('hello-world')).rejects.toThrowError( | |
new Error( | |
'Only images distributed via docker.pkg.github.com or ghcr.io can be fetched' | |
) | |
) | |
}) | |
}) | |
}) |