mirror of https://github.com/databricks/cli.git
Clone ReplacementContext before passing into test (#2198)
## Changes - Add a new method Clone() on ReplacementContext - Use it when passing common replacements to test cases. ## Tests Manually. I have a different branch where this bug manifested and this change helped.
This commit is contained in:
parent
de5155ed0a
commit
34a37cf4a8
|
@ -99,7 +99,7 @@ func TestAccept(t *testing.T) {
|
||||||
testName := strings.ReplaceAll(dir, "\\", "/")
|
testName := strings.ReplaceAll(dir, "\\", "/")
|
||||||
t.Run(testName, func(t *testing.T) {
|
t.Run(testName, func(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
runTest(t, dir, coverDir, repls)
|
runTest(t, dir, coverDir, repls.Clone())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"slices"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/databricks/cli/internal/testutil"
|
"github.com/databricks/cli/internal/testutil"
|
||||||
|
@ -31,6 +32,10 @@ type ReplacementsContext struct {
|
||||||
Repls []Replacement
|
Repls []Replacement
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *ReplacementsContext) Clone() ReplacementsContext {
|
||||||
|
return ReplacementsContext{Repls: slices.Clone(r.Repls)}
|
||||||
|
}
|
||||||
|
|
||||||
func (r *ReplacementsContext) Replace(s string) string {
|
func (r *ReplacementsContext) Replace(s string) string {
|
||||||
// QQQ Should probably only replace whole words
|
// QQQ Should probably only replace whole words
|
||||||
for _, repl := range r.Repls {
|
for _, repl := range r.Repls {
|
||||||
|
|
Loading…
Reference in New Issue