Giter Site home page Giter Site logo

Comments (6)

Fs02 avatar Fs02 commented on August 15, 2024

hmm, this package should be compatible with go-rel/rel/reltest, so this is a bug and needs to be fixed.

alternative way to fix that is, by specifying how many times the calls will happens:

	repo.ExpectTransaction(func(repo *Repository) {
		repo.ExpectInsert()
		repo.ExpectUpdate().Success().Times(1)
		repo.ExpectUpdate().ConnectionClosed()
	})

from reltest.

Fs02 avatar Fs02 commented on August 15, 2024

looks like the missing feature from testify/mock is the ability to find a better mocks.
https://github.com/stretchr/testify/blob/acba37e5db06f0093b465a7d47822bf13644b66c/mock/mock.go#L321-L323

we should try to prioritize mocks based on:

  • number of matched attributes (full match or partial match using any)
  • type or table match
  • repeatability and total calls (repeatability > 0 or totallCalls == 0 should be prioritized)

the last criteria should makes your test pass

from reltest.

Fs02 avatar Fs02 commented on August 15, 2024

But looks like that implementation is too complex to be added here, too many possible mocks variations (struct, partial struct, table, type, query etc) in reltest matcher πŸ€”

My other idea is to make repo.ExpectUpdate().Success().Times(1) as default behavior, unless Many (repo.ExpectUpdate().Success().Many() is specified).

let me know if you have any thought

from reltest.

ddanurwenda avatar ddanurwenda commented on August 15, 2024

I always thought repo.ExpectX() without additional assertion is equal to repo.ExpectX().Success().Times(1), at least that's how I used go-rel/rel/reltest. I think setting it as default behavior is a good idea πŸ‘

from reltest.

Fs02 avatar Fs02 commented on August 15, 2024

Agree, let’s do that!

from reltest.

Fs02 avatar Fs02 commented on August 15, 2024

this changes has been released as v0.4.0: https://github.com/go-rel/reltest/releases/tag/v0.4.0
sorry for the late release πŸ™

from reltest.

Related Issues (5)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.