Skip to content

Commit

Permalink
Merge pull request juju#17361 from hpidcock/typed-mock-returns
Browse files Browse the repository at this point in the history
juju#17361

Gomock has a new-ish feature to implement typed Return/Do/DoAndReturn methods on the EXPECT types.

This enables it on all the mockgen calls and fixes up all the related issues from that.

## QA steps

Unit tests should pass.

## Documentation changes

N/A

## Links

**Jira card:** JUJU-
  • Loading branch information
jujubot authored May 8, 2024
2 parents 89e7602 + 89b9da7 commit 9a19972
Show file tree
Hide file tree
Showing 905 changed files with 167,041 additions and 14,101 deletions.
3 changes: 2 additions & 1 deletion agent/addons/addons_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,9 @@ func (s *registerSuite) TestRegisterEngineMetrics(c *gc.C) {

registry := NewMockRegisterer(ctrl)
registry.EXPECT().Register(collector)
registry.EXPECT().Unregister(collector).Do(func(_ prometheus.Collector) {
registry.EXPECT().Unregister(collector).Do(func(_ prometheus.Collector) bool {
close(done)
return false
})
sink := NewMockMetricSink(ctrl)
sink.EXPECT().Unregister()
Expand Down
58 changes: 53 additions & 5 deletions agent/addons/engine_mock_test.go

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

4 changes: 2 additions & 2 deletions agent/addons/package_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
gc "gopkg.in/check.v1"
)

//go:generate go run go.uber.org/mock/mockgen -package addons_test -destination prometheus_mock_test.go github.com/prometheus/client_golang/prometheus Registerer
//go:generate go run go.uber.org/mock/mockgen -package addons_test -destination engine_mock_test.go github.com/juju/juju/agent/engine MetricSink
//go:generate go run go.uber.org/mock/mockgen -typed -package addons_test -destination prometheus_mock_test.go github.com/prometheus/client_golang/prometheus Registerer
//go:generate go run go.uber.org/mock/mockgen -typed -package addons_test -destination engine_mock_test.go github.com/juju/juju/agent/engine MetricSink

func Test(t *testing.T) {
gc.TestingT(t)
Expand Down
86 changes: 79 additions & 7 deletions agent/addons/prometheus_mock_test.go

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

Loading

0 comments on commit 9a19972

Please sign in to comment.