-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: kvanzuijlen <[email protected]>
- Loading branch information
1 parent
ac5a360
commit 869fd72
Showing
7 changed files
with
314 additions
and
33 deletions.
There are no files selected for viewing
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
29 changes: 29 additions & 0 deletions
29
lib/modules/manager/helm-values/__snapshots__/update.spec.ts.snap
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`lib/manager/helm-values/update .bumpPackageVersion() increments 1`] = ` | ||
"apiVersion: v2 | ||
name: test | ||
version: 0.0.3 | ||
" | ||
`; | ||
|
||
exports[`lib/manager/helm-values/update .bumpPackageVersion() updates 1`] = ` | ||
"apiVersion: v2 | ||
name: test | ||
version: 0.1.0 | ||
" | ||
`; | ||
|
||
exports[`modules/manager/helm-values/update .bumpPackageVersion() increments 1`] = ` | ||
"apiVersion: v2 | ||
name: test | ||
version: 0.0.3 | ||
" | ||
`; | ||
|
||
exports[`modules/manager/helm-values/update .bumpPackageVersion() updates 1`] = ` | ||
"apiVersion: v2 | ||
name: test | ||
version: 0.1.0 | ||
" | ||
`; |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import yaml from 'js-yaml'; | ||
import { fs } from '../../../../test/util'; | ||
import * as helmValuesUpdater from './update'; | ||
|
||
describe('modules/manager/helm-values/update', () => { | ||
describe('.bumpPackageVersion()', () => { | ||
const chartContent = yaml.dump({ | ||
apiVersion: 'v2', | ||
name: 'test', | ||
version: '0.0.2', | ||
}); | ||
const helmValuesContent = yaml.dump({ | ||
image: { | ||
registry: 'docker.io', | ||
repository: 'docker/whalesay', | ||
tag: '1.0.0', | ||
}, | ||
}); | ||
|
||
beforeEach(() => { | ||
jest.resetAllMocks(); | ||
fs.readLocalFile = jest.fn(); | ||
fs.readLocalFile.mockResolvedValueOnce(chartContent); | ||
}); | ||
|
||
it('increments', async () => { | ||
const { bumpedContent, bumpedFiles } = | ||
await helmValuesUpdater.bumpPackageVersion( | ||
helmValuesContent, | ||
'0.0.2', | ||
'patch', | ||
'values.yaml', | ||
); | ||
expect(bumpedContent).toEqual(helmValuesContent); | ||
expect(bumpedFiles).toHaveLength(1); | ||
const bumpedFile = bumpedFiles![0]; | ||
expect(bumpedFile.fileName).toBe('Chart.yaml'); | ||
expect(bumpedFile.newContent).toMatchSnapshot(); | ||
}); | ||
|
||
it('no ops', async () => { | ||
const { bumpedContent, bumpedFiles } = | ||
await helmValuesUpdater.bumpPackageVersion( | ||
helmValuesContent, | ||
'0.0.1', | ||
'patch', | ||
'values.yaml', | ||
); | ||
expect(bumpedContent).toEqual(helmValuesContent); | ||
expect(bumpedFiles).toHaveLength(1); | ||
const bumpedFile = bumpedFiles![0]; | ||
expect(bumpedFile.newContent).toEqual(chartContent); | ||
}); | ||
|
||
it('updates', async () => { | ||
const { bumpedContent, bumpedFiles } = | ||
await helmValuesUpdater.bumpPackageVersion( | ||
helmValuesContent, | ||
'0.0.1', | ||
'minor', | ||
'values.yaml', | ||
); | ||
expect(bumpedContent).toEqual(helmValuesContent); | ||
expect(bumpedFiles).toHaveLength(1); | ||
const bumpedFile = bumpedFiles![0]; | ||
expect(bumpedFile.fileName).toBe('Chart.yaml'); | ||
expect(bumpedFile.newContent).toMatchSnapshot(); | ||
}); | ||
|
||
it('returns content if bumping errors', async () => { | ||
const { bumpedContent, bumpedFiles } = | ||
await helmValuesUpdater.bumpPackageVersion( | ||
helmValuesContent, | ||
'0.0.2', | ||
true as any, | ||
'values.yaml', | ||
); | ||
expect(bumpedContent).toEqual(helmValuesContent); | ||
expect(bumpedFiles).toBeUndefined(); | ||
}); | ||
}); | ||
}); |
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
Oops, something went wrong.