mirror of https://github.com/databricks/cli.git
added error for when CLI is not installed
This commit is contained in:
parent
3959ca1317
commit
e6000db8c5
|
@ -11,7 +11,6 @@ import (
|
|||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
// TODO: add assertion for error if git CLI is not found
|
||||
func TestAccGitClonePublicRepository(t *testing.T) {
|
||||
t.Log(GetEnvOrSkipTest(t, "CLOUD_ENV"))
|
||||
|
||||
|
|
|
@ -96,6 +96,9 @@ func clonePrivate(ctx context.Context, opts CloneOptions) error {
|
|||
|
||||
// start git clone
|
||||
err := cmd.Start()
|
||||
if errors.Is(err, exec.ErrNotFound) {
|
||||
return fmt.Errorf("please install git CLI to download private templates: %w", err)
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
package git
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"os/exec"
|
||||
"testing"
|
||||
|
||||
"github.com/databricks/cli/libs/cmdio"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestGitCloneCLINotFound(t *testing.T) {
|
||||
// Set PATH to "", so git CLI cannot be found
|
||||
t.Setenv("PATH", "")
|
||||
|
||||
tmpDir := t.TempDir()
|
||||
cmdIO := cmdio.NewIO("text", os.Stdin, os.Stdout, os.Stderr, "")
|
||||
ctx := cmdio.InContext(context.Background(), cmdIO)
|
||||
|
||||
err := Clone(ctx, CloneOptions{
|
||||
Provider: "github",
|
||||
Organization: "databricks",
|
||||
RepositoryName: "does-not-exist",
|
||||
Reference: "main",
|
||||
TargetDir: tmpDir,
|
||||
})
|
||||
assert.ErrorIs(t, err, exec.ErrNotFound)
|
||||
assert.ErrorContains(t, err, "please install git CLI to download private templates")
|
||||
}
|
Loading…
Reference in New Issue