Skip to content

Commit

Permalink
persistence/client/factory.go test coverage (#5859)
Browse files Browse the repository at this point in the history
Our ability to cover this file is rather harshly limited due to it directly calling funcs in other packages that try to make network connections... but thankfully the DataStore-based stuff can be intercepted.  So I've at least tested those branches.

More generally this package is yet another strong argument in favor of leaning more on go.uber.org/fx for dependency injection.  Very little of this has to be (or should be) hard-coded in this file.  It feels like Java's "Service Locator" pattern, but even worse because the language doesn't allow test controls of globals like Java does... so I doubt it's a coincidence that there's a `bean.go` file in here.
  • Loading branch information
Groxx authored Apr 8, 2024
1 parent c7d1957 commit 604b55c
Show file tree
Hide file tree
Showing 4 changed files with 571 additions and 9 deletions.
10 changes: 1 addition & 9 deletions common/log/testlogger/testlogger.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@
package testlogger

import (
"testing"

"github.com/stretchr/testify/require"
"go.uber.org/zap/zaptest"

"github.com/uber/cadence/common/log"
Expand All @@ -34,11 +31,6 @@ import (

// New is a helper to create new development logger in unit test
func New(t zaptest.TestingT) log.Logger {
if testing.Verbose() {
logger, err := loggerimpl.NewDevelopment()
require.NoError(t, err)
return logger
}
// test logger samples all logs
// test logger that emits all logs (none dropped / sample func never returns false)
return loggerimpl.NewLogger(zaptest.NewLogger(t), loggerimpl.WithSampleFunc(func(int) bool { return true }))
}
2 changes: 2 additions & 0 deletions common/persistence/client/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

//go:generate mockgen -package $GOPACKAGE -source $GOFILE -destination factory_mock.go

package client

import (
Expand Down
346 changes: 346 additions & 0 deletions common/persistence/client/factory_mock.go

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

Loading

0 comments on commit 604b55c

Please sign in to comment.