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

Failed test at Mocking tutorial #808

Open
TheInvincibleRalph opened this issue Aug 27, 2024 · 2 comments
Open

Failed test at Mocking tutorial #808

TheInvincibleRalph opened this issue Aug 27, 2024 · 2 comments

Comments

@TheInvincibleRalph
Copy link

The implemetation here:

func Countdown(out io.Writer, sleeper Sleeper) {
	for i := countdownStart; i > 0; i-- {
		sleeper.Sleep()
	}

	for i := countdownStart; i > 0; i-- {
		fmt.Fprintln(out, i)
	}

	fmt.Fprint(out, finalWord)
}

gives this error:

--- FAIL: TestCountdown (0.00s)
    --- FAIL: TestCountdown/sleep_before_every_print (0.00s)
        c:\Testing\mocking\mocking_test.go:60: wanted calls [write sleep write sleep write sleep write] got [sleep sleep sleep write write write write]
FAIL
@quii
Copy link
Owner

quii commented Aug 27, 2024

I'm not sure exactly where you are, so it's very hard for me to offer any help, but these tests do pass.

Maybe have a look here https://github.com/quii/learn-go-with-tests/tree/main/mocking/v5

@TheInvincibleRalph
Copy link
Author

TheInvincibleRalph commented Aug 27, 2024

The function was refactored in the main file you sent:

func Countdown(out io.Writer, sleeper Sleeper) {

	for i := countdownStart; i > 0; i-- {
		fmt.Fprintln(out, i)
		sleeper.Sleep()
	}

	fmt.Fprint(out, finalWord)
}

but the change was not later made in the tutorial here: https://github.com/quii/learn-go-with-tests/blob/main/mocking.md

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

2 participants