Skip to content

Commit d450f3b

Browse files
committed
fixup! feat(new tool): Env Variables Converter
1 parent d2e32ac commit d450f3b

File tree

2 files changed

+34
-45
lines changed

2 files changed

+34
-45
lines changed
Lines changed: 19 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
1-
import { describe, expect } from 'vitest';
2-
import { Formats } from '../components/home/main/Main';
1+
import { describe, expect, it } from 'vitest';
2+
import { Formats } from './formats';
33
import inputHandler from './inputHandler';
44

5-
describe('simplifies input', () => {
6-
const input = ` - name: SPRING_CACHE_TYPE
5+
describe('inputHandler', () => {
6+
it('simplifies input', () => {
7+
const input = ` - name: SPRING_CACHE_TYPE
78
value: redis
89
- name: SPRING_REDIS_SSL
910
value: true`;
10-
expect(inputHandler(Formats.KUBERNETES, input))
11-
.toStrictEqual({ SPRING_CACHE_TYPE: 'redis', SPRING_REDIS_SSL: 'true' });
12-
});
11+
expect(inputHandler(Formats.KUBERNETES, input))
12+
.toStrictEqual({ SPRING_CACHE_TYPE: 'redis', SPRING_REDIS_SSL: 'true' });
13+
});
1314

14-
// https://stackoverflow.com/a/21699210/1098564
15-
describe('simplifies input quotations', () => {
16-
const input = `
15+
// https://stackoverflow.com/a/21699210/1098564
16+
it('simplifies input quotations', () => {
17+
const input = `
1718
- name: SPRING_CACHE_TYPE
1819
value: redis
1920
- name: >-
@@ -30,31 +31,17 @@ describe('simplifies input quotations', () => {
3031
SPRING_REDIS_SSL3
3132
value: 'redis'`;
3233

33-
expect(inputHandler(Formats.KUBERNETES, input))
34-
.toStrictEqual({ SPRING_CACHE_TYPE: 'redis', SPRING_REDIS_SSL: 'don\'t', SPRING_REDIS_SSL1: 'don\'t', SPRING_REDIS_SSL2: 'don\'t', SPRING_REDIS_SSL3: 'redis' });
35-
});
36-
37-
// // https://stackoverflow.com/a/21699210/1098564
38-
// test('block style chomp strip', () => {
39-
// const input = `
40-
// - name: SOME_KEY
41-
// value: >-
42-
// very "long"
43-
// 'string' with
44-
45-
// paragraph gap, \n and
46-
// spaces.
47-
// `
48-
// expect(inputHandler(Formats.KUBERNETES, input))
49-
// .toStrictEqual({"SOME_KEY": "very \"long\" 'string' with\nparagraph gap, \\n and spaces."});
50-
// });
34+
expect(inputHandler(Formats.KUBERNETES, input))
35+
.toStrictEqual({ SPRING_CACHE_TYPE: 'redis', SPRING_REDIS_SSL: 'don\'t', SPRING_REDIS_SSL1: 'don\'t', SPRING_REDIS_SSL2: 'don\'t', SPRING_REDIS_SSL3: 'redis' });
36+
});
5137

52-
describe('simplifies input properties quotes', () => {
53-
const input = `foo-bar.baz[0]=value1
38+
it('simplifies input properties quotes', () => {
39+
const input = `foo-bar.baz[0]=value1
5440
foo-bar.baz[1]=value2
5541
foo-bar.enabled=true
5642
abcDef=value3
5743
`;
58-
expect(inputHandler(Formats.PROPERTIES, input))
59-
.toStrictEqual({ 'abcDef': 'value3', 'foo-bar': { baz: ['value1', 'value2'], enabled: 'true' } });
44+
expect(inputHandler(Formats.PROPERTIES, input))
45+
.toStrictEqual({ 'abcDef': 'value3', 'foo-bar': { baz: ['value1', 'value2'], enabled: 'true' } });
46+
});
6047
});
Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,34 @@
1-
import { describe, expect } from 'vitest';
2-
import { Formats } from '../formats';
1+
import { describe, expect, it } from 'vitest';
2+
import { Formats } from './formats';
33
import outputFormatter from './outputFormatter';
44

5-
describe('yaml format', () => {
6-
const input = `foo-bar.baz[0]=value1
5+
describe('outputFormatter', () => {
6+
it('yaml format', () => {
7+
const input = `foo-bar.baz[0]=value1
78
foo-bar.baz[1]=value2
89
foo-bar.enabled=true
910
abcDef=value3
10-
`.split('\n');
11+
`.split('\n');
1112

12-
expect(outputFormatter(Formats.YAML, input))
13-
.toStrictEqual(
14-
`foo-bar:
13+
expect(outputFormatter(Formats.YAML, input))
14+
.toStrictEqual(
15+
`foo-bar:
1516
baz:
1617
- value1
1718
- value2
1819
enabled: true
1920
abcDef: value3
2021
`);
21-
});
22+
});
2223

23-
describe('k8s format', () => {
24-
const input = `foo-bar.baz[0]=value1
24+
it('k8s format', () => {
25+
const input = `foo-bar.baz[0]=value1
2526
foo-bar.baz[1]=value2
2627
foo-bar.enabled=true
2728
abcDef=value3`.split('\n');
2829

29-
expect(outputFormatter(Formats.KUBERNETES, input))
30-
.toStrictEqual(
30+
expect(outputFormatter(Formats.KUBERNETES, input))
31+
.toStrictEqual(
3132
`- name: FOOBAR_BAZ_0_
3233
value: 'value1'
3334
- name: FOOBAR_BAZ_1_
@@ -37,4 +38,5 @@ abcDef=value3`.split('\n');
3738
- name: ABCDEF
3839
value: 'value3'
3940
`);
41+
});
4042
});

0 commit comments

Comments
 (0)