mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-10 04:22:12 +00:00
### Related Issues Allow the `ls` commands to have a `--limit` option that allows a user to fetch up to 100 records per page. Currently the default is 20, but the API allows up to 100. This keeps the default, if unspecified at 20. Fixes: https://linear.app/vercel/issue/VCCLI-244/add-limit-option-all-the-ls-subcommands This adds in `ls --limit` into: - [x] `alias ls` - [x] `certs ls` - [x] `dns ls` - [x] `domains ls` I note that `env` has an `ls` command, but it doesn't have a pagination command and [looking at the API](https://vercel.com/docs/rest-api#endpoints/projects/retrieve-the-environment-variables-of-a-project-by-id-or-name) it doesn't support pagination or limit. Wasn't sure if I should add in `-L` as a short cut to `--limit`, seems like a good idea. ~Couldn't find any tests that cover this API, but I could be looking in the wrong place, this is the first pull request, so my apologies if I've missed it. But I'll take another look tomorrow and leave it in the draft state for now.~ Added in unit tests for each of the commands and mocks for those unit tests, which is has caused this PR to get quite a bit larger, sorry about that. Of note for reviewers, there were a few places where I changed `console.log` to `output.log` to get the output passed to the tests - as far as I can tell everything works on the command line and in tests. ### 📋 Checklist #### Tests - [x] The code changed/added as part of this PR has been covered with tests - [x] All tests pass locally with `yarn test-unit` #### Code Review - [x] This PR has a concise title and thorough description useful to a reviewer - [x] Issue from task tracker has a link to this PR
25 lines
785 B
TypeScript
25 lines
785 B
TypeScript
import { client } from '../../mocks/client';
|
|
import dns from '../../../src/commands/dns';
|
|
import { useUser } from '../../mocks/user';
|
|
import { useDns } from '../../mocks/dns';
|
|
|
|
describe('dns', () => {
|
|
it('should list up to 20 dns by default', async () => {
|
|
useUser();
|
|
useDns();
|
|
client.setArgv('dns', 'ls');
|
|
let exitCodePromise = dns(client);
|
|
await expect(client.stderr).toOutput('example-19.com');
|
|
await expect(exitCodePromise).resolves.toEqual(0);
|
|
});
|
|
|
|
it('should list up to 2 dns if limit set to 2', async () => {
|
|
useUser();
|
|
useDns();
|
|
client.setArgv('dns', 'ls', '--limit', 2);
|
|
let exitCodePromise = dns(client);
|
|
await expect(client.stderr).toOutput('example-2.com');
|
|
await expect(exitCodePromise).resolves.toEqual(0);
|
|
});
|
|
});
|