Skip to content

Commit cf03f85

Browse files
committed
chore: removed redundant tests
1 parent b763dc8 commit cf03f85

File tree

2 files changed

+0
-64
lines changed

2 files changed

+0
-64
lines changed

src/utils/parsers.ts

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -196,38 +196,6 @@ const parsePort: (data: string) => Port = validateParserToArgParser(
196196
const parseSeedNodes: (data: string) => [SeedNodes, boolean] =
197197
validateParserToArgParser(nodesUtils.parseSeedNodes);
198198

199-
/**
200-
* This parses the arguments used for the env command. It should be formatted as
201-
* <secretPath...> [-- cmd [cmdArgs...]]
202-
* The cmd part of the list is separated by using `--`.
203-
*/
204-
function parseEnvArgs(
205-
value: string,
206-
prev: [Array<ParsedSecretPathValue>, Array<string>, boolean] | undefined,
207-
): [Array<ParsedSecretPathValue>, Array<string>, boolean] {
208-
const current: [Array<ParsedSecretPathValue>, Array<string>, boolean] =
209-
prev ?? [[], [], false];
210-
const [secretsList, commandList, parsingCommandCurrent] = current;
211-
let parsingCommand = parsingCommandCurrent;
212-
if (!parsingCommand) {
213-
// Parse a secret path
214-
if (value !== '--') {
215-
secretsList.push(parseSecretPathEnv(value));
216-
} else {
217-
parsingCommand = true;
218-
}
219-
} else {
220-
// Otherwise we just have the cmd args
221-
commandList.push(value);
222-
}
223-
if (secretsList.length === 0 && commandList.length > 0) {
224-
throw new commander.InvalidArgumentError(
225-
'You must provide at least 1 secret path',
226-
);
227-
}
228-
return [secretsList, commandList, parsingCommand];
229-
}
230-
231199
export {
232200
vaultNameRegex,
233201
secretPathRegex,
@@ -256,5 +224,4 @@ export {
256224
parseProviderId,
257225
parseIdentityId,
258226
parseProviderIdList,
259-
parseEnvArgs,
260227
};

tests/secrets/env.test.ts

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import type { VaultName } from 'polykey/dist/vaults/types';
2-
import type { ParsedSecretPathValue } from '@/types';
32
import path from 'path';
43
import fs from 'fs';
54
import fc from 'fast-check';
@@ -9,7 +8,6 @@ import PolykeyAgent from 'polykey/dist/PolykeyAgent';
98
import { vaultOps } from 'polykey/dist/vaults';
109
import * as keysUtils from 'polykey/dist/keys/utils';
1110
import { sysexits } from 'polykey/dist/utils';
12-
import * as binParsers from '@/utils/parsers';
1311
import * as testUtils from '../utils';
1412

1513
describe('commandEnv', () => {
@@ -865,35 +863,6 @@ describe('commandEnv', () => {
865863
expect(jsonOut2[secretName2]).toBe(secretContent2);
866864
expect(jsonOut2[secretName3]).toBe(secretContent3);
867865
});
868-
test.prop([
869-
testUtils.secretPathEnvArrayArb,
870-
fc.string().noShrink(),
871-
testUtils.cmdArgsArrayArb,
872-
])(
873-
'parse secrets env arguments',
874-
async (secretPathEnvArray, cmd, cmdArgsArray) => {
875-
let output:
876-
| [Array<ParsedSecretPathValue>, Array<string>, boolean]
877-
| undefined = undefined;
878-
// By running the parser directly, we are bypassing commander, so it works
879-
// with a single --
880-
const args: Array<string> = [
881-
...secretPathEnvArray,
882-
'--',
883-
cmd,
884-
...cmdArgsArray,
885-
];
886-
for (const arg of args) {
887-
output = binParsers.parseEnvArgs(arg, output);
888-
}
889-
const [parsedEnvs, parsedArgs] = output!;
890-
const expectedSecretPathArray = secretPathEnvArray.map((v) => {
891-
return binParsers.parseSecretPath(v);
892-
});
893-
expect(parsedEnvs).toMatchObject(expectedSecretPathArray);
894-
expect(parsedArgs).toMatchObject([cmd, ...cmdArgsArray]);
895-
},
896-
);
897866
test('handles no arguments', async () => {
898867
const command = ['secrets', 'env', '-np', dataDir, '--env-format', 'unix'];
899868
const result = await testUtils.pkExec(command, {

0 commit comments

Comments
 (0)