Skip to content

Commit

Permalink
Merge branch 'main' into python-override
Browse files Browse the repository at this point in the history
  • Loading branch information
kanterov authored May 13, 2024
2 parents f04723f + 95bbe2e commit 8dfa383
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 21 deletions.
27 changes: 18 additions & 9 deletions bundle/parallel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package bundle

import (
"context"
"sync"
"testing"

"github.com/databricks/cli/bundle/config"
Expand All @@ -10,19 +11,25 @@ import (
)

type addToContainer struct {
t *testing.T
container *[]int
value int
err bool

// mu is a mutex that protects container. It is used to ensure that the
// container slice is only modified by one goroutine at a time.
mu *sync.Mutex
}

func (m *addToContainer) Apply(ctx context.Context, b ReadOnlyBundle) diag.Diagnostics {
if m.err {
return diag.Errorf("error")
}

c := *m.container
c = append(c, m.value)
*m.container = c
m.mu.Lock()
*m.container = append(*m.container, m.value)
m.mu.Unlock()

return nil
}

Expand All @@ -36,9 +43,10 @@ func TestParallelMutatorWork(t *testing.T) {
}

container := []int{}
m1 := &addToContainer{container: &container, value: 1}
m2 := &addToContainer{container: &container, value: 2}
m3 := &addToContainer{container: &container, value: 3}
var mu sync.Mutex
m1 := &addToContainer{t: t, container: &container, value: 1, mu: &mu}
m2 := &addToContainer{t: t, container: &container, value: 2, mu: &mu}
m3 := &addToContainer{t: t, container: &container, value: 3, mu: &mu}

m := Parallel(m1, m2, m3)

Expand All @@ -57,9 +65,10 @@ func TestParallelMutatorWorkWithErrors(t *testing.T) {
}

container := []int{}
m1 := &addToContainer{container: &container, value: 1}
m2 := &addToContainer{container: &container, err: true, value: 2}
m3 := &addToContainer{container: &container, value: 3}
var mu sync.Mutex
m1 := &addToContainer{container: &container, value: 1, mu: &mu}
m2 := &addToContainer{container: &container, err: true, value: 2, mu: &mu}
m3 := &addToContainer{container: &container, value: 3, mu: &mu}

m := Parallel(m1, m2, m3)

Expand Down
7 changes: 3 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,16 @@ require (
github.com/stretchr/testify v1.9.0 // MIT
golang.org/x/exp v0.0.0-20240222234643-814bf88cf225
golang.org/x/mod v0.17.0
golang.org/x/oauth2 v0.19.0
golang.org/x/oauth2 v0.20.0
golang.org/x/sync v0.7.0
golang.org/x/term v0.19.0
golang.org/x/text v0.14.0
golang.org/x/text v0.15.0
gopkg.in/ini.v1 v1.67.0 // Apache 2.0
gopkg.in/yaml.v3 v3.0.1
)

require (
cloud.google.com/go/compute v1.23.4 // indirect
cloud.google.com/go/compute/metadata v0.2.3 // indirect
cloud.google.com/go/compute/metadata v0.3.0 // indirect
github.com/ProtonMail/go-crypto v1.1.0-alpha.2 // indirect
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e // indirect
Expand Down
14 changes: 6 additions & 8 deletions go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8dfa383

Please sign in to comment.