mirror of
https://github.com/psviderski/uncloud.git
synced 2026-08-28 20:13:33 +00:00
test: InspectGitState when git not available
This commit is contained in:
@@ -10,6 +10,22 @@ import (
|
|||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func TestInspectGitState_GitNotAvailable(t *testing.T) {
|
||||||
|
// Reset the PATH env var to simulate git not being available.
|
||||||
|
t.Setenv("PATH", "")
|
||||||
|
|
||||||
|
tmpDir := t.TempDir()
|
||||||
|
|
||||||
|
state, err := InspectGitState(tmpDir)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
assert.False(t, state.IsRepo)
|
||||||
|
assert.Empty(t, state.SHA)
|
||||||
|
assert.Empty(t, state.ShortSHA(7))
|
||||||
|
assert.True(t, state.Time.IsZero())
|
||||||
|
assert.False(t, state.IsDirty)
|
||||||
|
}
|
||||||
|
|
||||||
func TestInspectGitState_NotARepo(t *testing.T) {
|
func TestInspectGitState_NotARepo(t *testing.T) {
|
||||||
// Create a temporary directory that's not a git repo.
|
// Create a temporary directory that's not a git repo.
|
||||||
tmpDir := t.TempDir()
|
tmpDir := t.TempDir()
|
||||||
|
|||||||
Reference in New Issue
Block a user