Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

1.1 KB
Raw Blame
import { describe, expect, test } from 'bun:test';
import { decideAddAlias } from './add_alias';

describe('decideAddAlias', () => {
  test('alias is currently a physical index — error (use swap script)', () => {
    const out = decideAddAlias({
      alias: 'channels',
      targetIndex: 'channels_v1',
      aliasAlreadyOnTarget: false,
      aliasIsPhysicalIndex: true,
    });
    expect(out.kind).toBe('error');
  });

  test('alias already on target — no-op', () => {
    const out = decideAddAlias({
      alias: 'emails',
      targetIndex: 'emails_v2',
      aliasAlreadyOnTarget: true,
      aliasIsPhysicalIndex: false,
    });
    expect(out.kind).toBe('noop');
  });

  test('alias does not exist anywhere — apply add', () => {
    const out = decideAddAlias({
      alias: 'emails',
      targetIndex: 'emails_v2',
      aliasAlreadyOnTarget: false,
      aliasIsPhysicalIndex: false,
    });
    expect(out.kind).toBe('apply');
    if (out.kind === 'apply') {
      expect(out.action).toEqual({
        add: { index: 'emails_v2', alias: 'emails' },
      });
    }
  });
});