Skip to content

Commit

Permalink
test(yaml): add test for YAML tags
Browse files Browse the repository at this point in the history
  • Loading branch information
websi committed Oct 4, 2024
1 parent 4d04357 commit 6f7ddbc
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
26 changes: 26 additions & 0 deletions lib/modules/manager/docker-compose/extract.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,32 @@ describe('modules/manager/docker-compose/extract', () => {
expect(res?.deps).toHaveLength(1);
});

it('extracts can parse yaml tags for version 3', () => {
const compose = codeBlock`
web:
image: node:20.0.0
ports:
- "80:8000"
worker:
extends:
service: web
ports: !reset null
`;
const res = extractPackageFile(compose, '', {});
expect(res).toEqual({
deps: [
{
depName: 'node',
currentValue: '20.0.0',
currentDigest: undefined,
replaceString: 'node:20.0.0',
autoReplaceStringTemplate: '{{depName}}{{#if newValue}}:{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}',
datasource: 'docker'
}
]
});
});

it('extracts image and replaces registry', () => {
const compose = codeBlock`
version: "3"
Expand Down
18 changes: 18 additions & 0 deletions lib/util/yaml.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,5 +281,23 @@ describe('util/yaml', () => {
},
});
});

it('should parse content with yaml tags', () => {
expect(
parseSingleYaml(
codeBlock`
myObject:
aString: value
aStringWithTag: !reset null
`,
{ removeTemplates: true },
),
).toEqual({
myObject: {
aString: 'value',
aStringWithTag: 'null',
},
});
});
});
});

0 comments on commit 6f7ddbc

Please sign in to comment.