Files
add-and-commit/test/io.test.ts
T
f0d523cb47 feat: treat pull: true as a default git pull (#498) (#773)
YAML true was passed through as git pull arguments, so pull: true ran `git pull true` instead of a default pull.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-14 21:15:51 +00:00

47 lines
1.6 KiB
TypeScript

import {parseBoolOrGitArgs, parsePushAttempts} from '../src/io';
describe('parseBoolOrGitArgs', () => {
const original = process.env.INPUT_PULL;
afterEach(() => {
if (original === undefined) delete process.env.INPUT_PULL;
else process.env.INPUT_PULL = original;
});
it('parses true/false as booleans', () => {
process.env.INPUT_PULL = 'true';
expect(parseBoolOrGitArgs('pull')).toBe(true);
process.env.INPUT_PULL = 'false';
expect(parseBoolOrGitArgs('pull')).toBe(false);
});
it('returns git-args strings unchanged', () => {
process.env.INPUT_PULL = '--rebase --autostash';
expect(parseBoolOrGitArgs('pull')).toBe('--rebase --autostash');
});
it('returns an empty string when unset', () => {
delete process.env.INPUT_PULL;
expect(parseBoolOrGitArgs('pull')).toBe('');
});
});
describe('parsePushAttempts', () => {
it('accepts positive integers', () => {
expect(parsePushAttempts('1')).toBe(1);
expect(parsePushAttempts('3')).toBe(3);
expect(parsePushAttempts(' 10 ')).toBe(10);
expect(parsePushAttempts('+2')).toBe(2);
});
it('rejects non-integers and values below 1', () => {
expect(() => parsePushAttempts('0')).toThrow(/positive integer/);
expect(() => parsePushAttempts('-1')).toThrow(/positive integer/);
expect(() => parsePushAttempts('1.5')).toThrow(/positive integer/);
expect(() => parsePushAttempts('true')).toThrow(/positive integer/);
expect(() => parsePushAttempts('')).toThrow(/positive integer/);
expect(() => parsePushAttempts('1e2')).toThrow(/positive integer/);
});
});