Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MockCharmStore.With{AuthAttrs,TestMode,DefaultSeries} are setters #69

Closed
davecheney opened this issue Nov 2, 2014 · 0 comments
Closed

Comments

@davecheney
Copy link
Contributor

func (s *MockCharmStore) WithAuthAttrs(auth string) charm.Repository {
    s.AuthAttrs = auth
    return s
}

func (s *MockCharmStore) WithTestMode(testMode bool) charm.Repository {
    s.TestMode = testMode
    return s
}

func (s *MockCharmStore) WithDefaultSeries(series string) charm.Repository {
    s.DefaultSeries = series
    return s
}

The following methods appear to return a copy of their receiver with a particular testing setting specified. However they do not, they modify their receiver and return themselves, not a copy.

This is bad for several reasons, none the least it produces a race condition as there is no synchronisation for these actions.

davecheney added a commit that referenced this issue Nov 3, 2014
Fixes #69

The code inside juju expects that these methods behave like setters.

Also add a mutex to make updating these values safe for multiple goroutines.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant