Skip to content
This repository was archived by the owner on Oct 6, 2025. It is now read-only.

Conversation

@doringeman
Copy link
Collaborator

$ make mock && make unit-tests
Generating mocks...
Mocks generated!
Running unit tests...
?   	github.com/docker/model-cli	[no test files]
?   	github.com/docker/model-cli/desktop	[no test files]
?   	github.com/docker/model-cli/mocks	[no test files]
=== RUN   TestStatus
=== RUN   TestStatus/running
=== RUN   TestStatus/not_running
=== RUN   TestStatus/request_with_error
=== RUN   TestStatus/failed_request
--- PASS: TestStatus (0.00s)
    --- PASS: TestStatus/running (0.00s)
    --- PASS: TestStatus/not_running (0.00s)
    --- PASS: TestStatus/request_with_error (0.00s)
    --- PASS: TestStatus/failed_request (0.00s)
PASS
ok  	github.com/docker/model-cli/commands	0.727s
Unit tests completed!

Copy link
Contributor

@ilopezluna ilopezluna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! 👏

cmd.Println("Docker Model Runner is not running")
hooks.PrintNextSteps(os.Stdout, []string{enableViaCLI, enableViaGUI})
os.Exit(1)
hooks.PrintNextSteps(cmd.OutOrStdout(), []string{enableViaCLI, enableViaGUI})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why cmd.OutOrStdout() instead of os.Stdout? Also why to extract os.Exit into a variable?
I assume it has to do with being able to assert the output in the test but I'm unsure of how it works.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I can capture it in the UT where I overwrite cmd's output.
https://github.com/docker/model-cli/pull/20/files/d706eeb6e5433e561bc3e661066ef3a1cfe07bd4

@doringeman doringeman merged commit 8a2867d into docker:main Apr 8, 2025
1 check passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants