Eshu
view release on metacpan or search on metacpan
t/0258-realworld-yaml.t view on Meta::CPAN
# 29
{
my $in = <<'END';
services:
web:
image: nginx
ports:
- '80:80'
db:
image: postgres
END
my $exp = <<'END';
services:
web:
image: nginx
ports:
- '80:80'
db:
image: postgres
END
is(ym($in), $exp, 'YAML: deeply over-indented normalised');
}
# 30
{
my $in = <<'END';
steps:
- name: checkout
uses: actions/checkout@v4
- name: test
run: npm test
env:
NODE_ENV: test
CI: 'true'
END
my $exp = <<'END';
steps:
- name: checkout
uses: actions/checkout@v4
- name: test
run: npm test
env:
NODE_ENV: test
CI: 'true'
END
is(ym($in), $exp, 'YAML: mixed indentation normalised');
}
# ââ idempotency tests ââââââââââââââââââââââââââââââââââââââââââââââ
for my $snippet (
"name: test\nvalue: 42\n",
"list:\n - a\n - b\n - c\n",
"nested:\n key: value\n inner:\n deep: true\n",
"services:\n app:\n image: nginx\n db:\n image: postgres\n",
"items:\n - id: 1\n name: first\n - id: 2\n name: second\n",
"config:\n host: localhost\n port: 5432\n ssl: true\n timeout: 30\n",
"matrix:\n include:\n - os: ubuntu\n version: '20'\n - os: macos\n version: '20'\n",
"env:\n production:\n debug: false\n log_level: error\n development:\n debug: true\n log_level: debug\n",
"pipeline:\n - lint\n - test\n - build\n - deploy\n",
"credentials:\n database:\n host: db.example.com\n port: 5432\n cache:\n host: cache.example.com\n port: 6379\n",
) {
my $once = ym($snippet);
is(ym($once), $once, 'YAML: snippet idempotent');
}
done_testing;
( run in 0.797 second using v1.01-cache-2.11-cpan-007c89162af )