Skip to content

test: add unit tests for state and git lib modules#76

Closed
TerminalGravity wants to merge 1 commit intomainfrom
test/add-state-and-git-tests
Closed

test: add unit tests for state and git lib modules#76
TerminalGravity wants to merge 1 commit intomainfrom
test/add-state-and-git-tests

Conversation

@TerminalGravity
Copy link
Collaborator

Adds 18 new unit tests covering two previously untested lib modules.

state.ts (10 tests): loadState, saveState, appendLog/readLog, now()
git.ts (8 tests): getBranch, getStatus, commits, staged files, error handling

Test count: 43 → 61. All green.

- 10 tests for state.ts: loadState, saveState, appendLog, readLog, now()
- 8 tests for git.ts: getBranch, getStatus, commits, staged files, error handling
- Coverage goes from 43 to 61 tests (42% increase)
@TerminalGravity
Copy link
Collaborator Author

CI fails because the git lib test creates commits but the runner has no git identity. Need to add git config user.email and git config user.name in the test setup (beforeAll) for the temp repo. Test logic itself looks good — just this env issue.

@TerminalGravity
Copy link
Collaborator Author

CI is failing — the git tests need git config user.name and user.email set in CI. The runner doesn't have a global git identity configured, so git commit fails with fatal: empty ident name.

Fix: add a setup step in the test (or in CI) to configure a dummy git identity:

beforeAll(() => {
  execSync('git config user.name "Test" && git config user.email "test@test.com"', { cwd: tmpDir });
});

Or add it to the CI workflow before npm test. The other test PRs all pass — this is the only one affected.

@TerminalGravity
Copy link
Collaborator Author

Superseded by newer test PRs (#117, #102).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant