testHistorySameInEveryCodebase

tcmts.cli.test.e2e.history.testHistorySameInEveryCodebase · #yr6rpcpy · term

History is the same in every codebase that has it.

import { tempDir } from "#codebase/tcmts/cli/test/e2e/harness";
import { codebase } from "#codebase/tcmts/cli/test/e2e/history";
import assert from "node:assert/strict";

export const testHistorySameInEveryCodebase = () => {
  const root = tempDir("history");
  const a = codebase(root, "a");
  const b = codebase(root, "b");
  a.tcm("init");
  a.write(`export const one = 1;\n`);
  a.tcm("add");
  a.write(`export const two = 2;\n`);
  a.tcm("add");
  b.tcm("init");
  b.tcm("remote", "add", "origin", a.dir);
  b.tcm("pull");
  assert.equal(b.entries().length, 2);
  assert.deepEqual(b.entries(), a.entries(), "pulled history has the same hashes");

  // the same change from the same point is the same causal (what made it, and when, aren't hashed)
  a.tcm("branch", "x");
  a.write(`export const three = 3;\n`);
  a.tcm("add");
  a.tcm("switch", "x");
  a.tcm("add");
  const onX = a.entries()[0];
  a.tcm("switch", "main");
  assert.equal(a.entries()[0], onX);
}

uses