mirror of
https://github.com/sharevb/it-tools.git
synced 2026-11-22 22:02:38 +03:00
fixup! feat(new tool): Env Variables Converter
This commit is contained in:
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 { describe, expect, it } from 'vitest';
|
||||||
import { Formats } from '../components/home/main/Main';
|
import { Formats } from './formats';
|
||||||
import inputHandler from './inputHandler';
|
import inputHandler from './inputHandler';
|
||||||
|
|
||||||
describe('simplifies input', () => {
|
describe('inputHandler', () => {
|
||||||
const input = ` - name: SPRING_CACHE_TYPE
|
it('simplifies input', () => {
|
||||||
|
const input = ` - name: SPRING_CACHE_TYPE
|
||||||
value: redis
|
value: redis
|
||||||
- name: SPRING_REDIS_SSL
|
- name: SPRING_REDIS_SSL
|
||||||
value: true`;
|
value: true`;
|
||||||
expect(inputHandler(Formats.KUBERNETES, input))
|
expect(inputHandler(Formats.KUBERNETES, input))
|
||||||
.toStrictEqual({ SPRING_CACHE_TYPE: 'redis', SPRING_REDIS_SSL: 'true' });
|
.toStrictEqual({ SPRING_CACHE_TYPE: 'redis', SPRING_REDIS_SSL: 'true' });
|
||||||
});
|
});
|
||||||
|
|
||||||
// https://stackoverflow.com/a/21699210/1098564
|
// https://stackoverflow.com/a/21699210/1098564
|
||||||
describe('simplifies input quotations', () => {
|
it('simplifies input quotations', () => {
|
||||||
const input = `
|
const input = `
|
||||||
- name: SPRING_CACHE_TYPE
|
- name: SPRING_CACHE_TYPE
|
||||||
value: redis
|
value: redis
|
||||||
- name: >-
|
- name: >-
|
||||||
@@ -30,31 +31,17 @@ describe('simplifies input quotations', () => {
|
|||||||
SPRING_REDIS_SSL3
|
SPRING_REDIS_SSL3
|
||||||
value: 'redis'`;
|
value: 'redis'`;
|
||||||
|
|
||||||
expect(inputHandler(Formats.KUBERNETES, input))
|
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' });
|
.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
|
it('simplifies input properties quotes', () => {
|
||||||
// test('block style chomp strip', () => {
|
const input = `foo-bar.baz[0]=value1
|
||||||
// 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
|
|
||||||
foo-bar.baz[1]=value2
|
foo-bar.baz[1]=value2
|
||||||
foo-bar.enabled=true
|
foo-bar.enabled=true
|
||||||
abcDef=value3
|
abcDef=value3
|
||||||
`;
|
`;
|
||||||
expect(inputHandler(Formats.PROPERTIES, input))
|
expect(inputHandler(Formats.PROPERTIES, input))
|
||||||
.toStrictEqual({ 'abcDef': 'value3', 'foo-bar': { baz: ['value1', 'value2'], enabled: 'true' } });
|
.toStrictEqual({ 'abcDef': 'value3', 'foo-bar': { baz: ['value1', 'value2'], enabled: 'true' } });
|
||||||
|
});
|
||||||
});
|
});
|
||||||
@@ -1,33 +1,34 @@
|
|||||||
import { describe, expect } from 'vitest';
|
import { describe, expect, it } from 'vitest';
|
||||||
import { Formats } from '../formats';
|
import { Formats } from './formats';
|
||||||
import outputFormatter from './outputFormatter';
|
import outputFormatter from './outputFormatter';
|
||||||
|
|
||||||
describe('yaml format', () => {
|
describe('outputFormatter', () => {
|
||||||
const input = `foo-bar.baz[0]=value1
|
it('yaml format', () => {
|
||||||
|
const input = `foo-bar.baz[0]=value1
|
||||||
foo-bar.baz[1]=value2
|
foo-bar.baz[1]=value2
|
||||||
foo-bar.enabled=true
|
foo-bar.enabled=true
|
||||||
abcDef=value3
|
abcDef=value3
|
||||||
`.split('\n');
|
`.split('\n');
|
||||||
|
|
||||||
expect(outputFormatter(Formats.YAML, input))
|
expect(outputFormatter(Formats.YAML, input))
|
||||||
.toStrictEqual(
|
.toStrictEqual(
|
||||||
`foo-bar:
|
`foo-bar:
|
||||||
baz:
|
baz:
|
||||||
- value1
|
- value1
|
||||||
- value2
|
- value2
|
||||||
enabled: true
|
enabled: true
|
||||||
abcDef: value3
|
abcDef: value3
|
||||||
`);
|
`);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('k8s format', () => {
|
it('k8s format', () => {
|
||||||
const input = `foo-bar.baz[0]=value1
|
const input = `foo-bar.baz[0]=value1
|
||||||
foo-bar.baz[1]=value2
|
foo-bar.baz[1]=value2
|
||||||
foo-bar.enabled=true
|
foo-bar.enabled=true
|
||||||
abcDef=value3`.split('\n');
|
abcDef=value3`.split('\n');
|
||||||
|
|
||||||
expect(outputFormatter(Formats.KUBERNETES, input))
|
expect(outputFormatter(Formats.KUBERNETES, input))
|
||||||
.toStrictEqual(
|
.toStrictEqual(
|
||||||
`- name: FOOBAR_BAZ_0_
|
`- name: FOOBAR_BAZ_0_
|
||||||
value: 'value1'
|
value: 'value1'
|
||||||
- name: FOOBAR_BAZ_1_
|
- name: FOOBAR_BAZ_1_
|
||||||
@@ -37,4 +38,5 @@ abcDef=value3`.split('\n');
|
|||||||
- name: ABCDEF
|
- name: ABCDEF
|
||||||
value: 'value3'
|
value: 'value3'
|
||||||
`);
|
`);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
Reference in new issue
Block a user