fixup! feat(new tool): Env Variables Converter

This commit is contained in:
ShareVB committed 2025-08-22 09:04:40 +02:00
1 parent d2e32ace21
commit d450f3b38c
2 files changed
+34 -45

No files matched your search

@@ -1,19 +1,20 @@
import { describe, expect } from 'vitest';
import { Formats } from '../components/home/main/Main';
import { describe, expect, it } from 'vitest';
import { Formats } from './formats';
import inputHandler from './inputHandler';
describe('simplifies input', () => {
const input = ` - name: SPRING_CACHE_TYPE
describe('inputHandler', () => {
it('simplifies input', () => {
const input = ` - name: SPRING_CACHE_TYPE
value: redis
- name: SPRING_REDIS_SSL
value: true`;
expect(inputHandler(Formats.KUBERNETES, input))
.toStrictEqual({ SPRING_CACHE_TYPE: 'redis', SPRING_REDIS_SSL: 'true' });
});
expect(inputHandler(Formats.KUBERNETES, input))
.toStrictEqual({ SPRING_CACHE_TYPE: 'redis', SPRING_REDIS_SSL: 'true' });
});
// https://stackoverflow.com/a/21699210/1098564
describe('simplifies input quotations', () => {
const input = `
// https://stackoverflow.com/a/21699210/1098564
it('simplifies input quotations', () => {
const input = `
- name: SPRING_CACHE_TYPE
value: redis
- name: >-
@@ -30,31 +31,17 @@ describe('simplifies input quotations', () => {
SPRING_REDIS_SSL3
value: 'redis'`;
expect(inputHandler(Formats.KUBERNETES, input))
.toStrictEqual({ SPRING_CACHE_TYPE: 'redis', SPRING_REDIS_SSL: 'don\'t', SPRING_REDIS_SSL1: 'don\'t', SPRING_REDIS_SSL2: 'don\'t', SPRING_REDIS_SSL3: 'redis' });
});
expect(inputHandler(Formats.KUBERNETES, input))
.toStrictEqual({ SPRING_CACHE_TYPE: 'redis', SPRING_REDIS_SSL: 'don\'t', SPRING_REDIS_SSL1: 'don\'t', SPRING_REDIS_SSL2: 'don\'t', SPRING_REDIS_SSL3: 'redis' });
});
// // https://stackoverflow.com/a/21699210/1098564
// test('block style chomp strip', () => {
// const input = `
// - name: SOME_KEY
// value: >-
// very "long"
// 'string' with
// paragraph gap, \n and
// spaces.
// `
// expect(inputHandler(Formats.KUBERNETES, input))
// .toStrictEqual({"SOME_KEY": "very \"long\" 'string' with\nparagraph gap, \\n and spaces."});
// });
describe('simplifies input properties quotes', () => {
const input = `foo-bar.baz[0]=value1
it('simplifies input properties quotes', () => {
const input = `foo-bar.baz[0]=value1
foo-bar.baz[1]=value2
foo-bar.enabled=true
abcDef=value3
`;
expect(inputHandler(Formats.PROPERTIES, input))
.toStrictEqual({ 'abcDef': 'value3', 'foo-bar': { baz: ['value1', 'value2'], enabled: 'true' } });
expect(inputHandler(Formats.PROPERTIES, input))
.toStrictEqual({ 'abcDef': 'value3', 'foo-bar': { baz: ['value1', 'value2'], enabled: 'true' } });
});
});
@@ -1,33 +1,34 @@
import { describe, expect } from 'vitest';
import { Formats } from '../formats';
import { describe, expect, it } from 'vitest';
import { Formats } from './formats';
import outputFormatter from './outputFormatter';
describe('yaml format', () => {
const input = `foo-bar.baz[0]=value1
describe('outputFormatter', () => {
it('yaml format', () => {
const input = `foo-bar.baz[0]=value1
foo-bar.baz[1]=value2
foo-bar.enabled=true
abcDef=value3
`.split('\n');
`.split('\n');
expect(outputFormatter(Formats.YAML, input))
.toStrictEqual(
`foo-bar:
expect(outputFormatter(Formats.YAML, input))
.toStrictEqual(
`foo-bar:
baz:
- value1
- value2
enabled: true
abcDef: value3
`);
});
});
describe('k8s format', () => {
const input = `foo-bar.baz[0]=value1
it('k8s format', () => {
const input = `foo-bar.baz[0]=value1
foo-bar.baz[1]=value2
foo-bar.enabled=true
abcDef=value3`.split('\n');
expect(outputFormatter(Formats.KUBERNETES, input))
.toStrictEqual(
expect(outputFormatter(Formats.KUBERNETES, input))
.toStrictEqual(
`- name: FOOBAR_BAZ_0_
value: 'value1'
- name: FOOBAR_BAZ_1_
@@ -37,4 +38,5 @@ abcDef=value3`.split('\n');
- name: ABCDEF
value: 'value3'
`);
});
});