31 lines
1.9 KiB
TypeScript
31 lines
1.9 KiB
TypeScript
import { describe, expect, test } from 'bun:test';
|
|
import { oldBuildLines, oldTrackBuilds } from '../cli/play/old-builds';
|
|
import { isAutoSendOnly, isReviewRefused } from '../cli/play/review-pending';
|
|
|
|
const tracks = [
|
|
{ track: 'production', releases: [{ name: '2.0.0 (10)', versionCodes: ['10'], status: 'completed' }] },
|
|
{ track: 'alpha', releases: [{ name: '1.0 (2)', versionCodes: ['2'], status: 'completed' }] },
|
|
{ track: 'beta', releases: [{ versionCodes: ['10'], status: 'completed' }] },
|
|
{ track: 'internal', releases: [{ versionCodes: ['3'], status: 'draft' }] },
|
|
{ track: 'qa-closed', releases: [{ versionCodes: ['4'], status: 'completed' }] },
|
|
];
|
|
|
|
describe('old builds on testing tracks (pitfall 129)', () => {
|
|
test('active builds below production are listed with the command that replaces them; drafts and current ones are not', () => {
|
|
const old = oldTrackBuilds(tracks);
|
|
expect(old.map(o => `${o.track}:${o.versionCodes.join(',')}`)).toEqual(['alpha:2', 'qa-closed:4']);
|
|
const text = oldBuildLines(old).join('\n');
|
|
expect(text).toContain('storebound play release --version-code 10 --alpha completed');
|
|
expect(text).toContain('--track qa-closed completed');
|
|
});
|
|
test('no production release: nothing to compare', () => {
|
|
expect(oldTrackBuilds(tracks.filter(t => t.track !== 'production'))).toEqual([]);
|
|
});
|
|
test('the "are sent for review automatically" 400 is told apart from the "cannot be sent" one', () => {
|
|
const auto = new Error('POST commit -> 400 {"error":{"message":"Changes are sent for review automatically.","errors":[{"reason":"badRequest"}]}}');
|
|
const refused = new Error('POST commit -> 400 {"error":{"message":"Changes cannot be sent for review automatically.","errors":[{"reason":"badRequest"}]}}');
|
|
expect(isAutoSendOnly(auto)).toBe(true);
|
|
expect(isAutoSendOnly(refused)).toBe(false);
|
|
expect(isReviewRefused(refused)).toBe(true);
|
|
});
|
|
});
|