MCPcopy Create free account
hub / github.com/github/gh-aw / TestSpec_Variables_ErrNotGitRepository

Function TestSpec_Variables_ErrNotGitRepository

pkg/gitutil/spec_test.go:349–361  ·  view source on GitHub ↗

TestSpec_Variables_ErrNotGitRepository validates the documented sentinel-error contract for ErrNotGitRepository. Specification (Variables + Behavioral contracts): - ErrNotGitRepository is the sentinel error returned by FindGitRoot and FindGitRootFrom when no .git entry is found while traversing up

(t *testing.T)

Source from the content-addressed store, hash-verified

347// The README usage example relies on errors.Is(err, gitutil.ErrNotGitRepository),
348// so the returned error must satisfy that comparison.
349func TestSpec_Variables_ErrNotGitRepository(t *testing.T) {
350 require.Error(t, gitutil.ErrNotGitRepository,
351 "ErrNotGitRepository should be a non-nil sentinel error value")
352
353 // A directory created outside any git repository should surface the
354 // documented sentinel error.
355 isolated := t.TempDir()
356 _, err := gitutil.FindGitRootFrom(isolated)
357 require.Error(t, err,
358 "FindGitRootFrom should error when startDir is not inside a git repository")
359 assert.ErrorIs(t, err, gitutil.ErrNotGitRepository,
360 "FindGitRootFrom should return the documented ErrNotGitRepository sentinel")
361}
362
363// TestSpec_PublicAPI_ReadFileFromHEAD validates the documented behavior of
364// ReadFileFromHEAD as described in the package README.md.

Callers

nothing calls this directly

Calls 2

FindGitRootFromFunction · 0.92
ErrorMethod · 0.45

Tested by

no test coverage detected