mirror of https://github.com/databricks/cli.git
handle os.ErrNotExist; update tests
This commit is contained in:
parent
1789cca2cb
commit
1e7d06cc3e
|
@ -2,6 +2,8 @@ package mutator
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/databricks/cli/bundle"
|
"github.com/databricks/cli/bundle"
|
||||||
|
@ -24,8 +26,10 @@ func (m *loadGitDetails) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagn
|
||||||
var diags diag.Diagnostics
|
var diags diag.Diagnostics
|
||||||
info, err := git.FetchRepositoryInfo(ctx, b.BundleRoot.Native(), b.WorkspaceClient())
|
info, err := git.FetchRepositoryInfo(ctx, b.BundleRoot.Native(), b.WorkspaceClient())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if !errors.Is(err, os.ErrNotExist) {
|
||||||
diags = append(diags, diag.WarningFromErr(err)...)
|
diags = append(diags, diag.WarningFromErr(err)...)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if info.WorktreeRoot == "" {
|
if info.WorktreeRoot == "" {
|
||||||
b.WorktreeRoot = b.BundleRoot
|
b.WorktreeRoot = b.BundleRoot
|
||||||
|
|
|
@ -101,7 +101,7 @@ func TestAccFetchRepositoryInfoAPI_FromNonRepo(t *testing.T) {
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
} else {
|
} else {
|
||||||
assert.Error(t, err)
|
assert.Error(t, err)
|
||||||
assert.Contains(t, err.Error(), test.msg)
|
assert.ErrorContains(t, err, test.msg)
|
||||||
}
|
}
|
||||||
assertEmptyGitInfo(t, info)
|
assertEmptyGitInfo(t, info)
|
||||||
})
|
})
|
||||||
|
@ -151,7 +151,7 @@ func TestAccFetchRepositoryInfoDotGit_FromNonGitRepo(t *testing.T) {
|
||||||
for _, input := range tests {
|
for _, input := range tests {
|
||||||
t.Run(input, func(t *testing.T) {
|
t.Run(input, func(t *testing.T) {
|
||||||
info, err := git.FetchRepositoryInfo(ctx, input, wt.W)
|
info, err := git.FetchRepositoryInfo(ctx, input, wt.W)
|
||||||
assert.NoError(t, err)
|
assert.ErrorIs(t, err, os.ErrNotExist)
|
||||||
assertEmptyGitInfo(t, info)
|
assertEmptyGitInfo(t, info)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue