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

Failing tests when running go test locally #243

Open
nathany-copia opened this issue Feb 23, 2023 · 1 comment
Open

Failing tests when running go test locally #243

nathany-copia opened this issue Feb 23, 2023 · 1 comment

Comments

@nathany-copia
Copy link

If I clone this repository and run the tests, I see several test failures. I took a look at ci.yml and I don't see a reason why these would fail unless:

  • My trial account has some difference with the key/secret vs. what's used in CI?
  • Something has changed, since CI hasn't ran these tests in a few months?
❯ STREAM_KEY={my api key} STREAM_SECRET={my secret} go test
--- FAIL: TestClient_UpdateAppSettings (0.25s)
    app_test.go:27: 
        	Error Trace:	app_test.go:27
        	Error:      	Received unexpected error:
        	            	UpdateApp failed with error: "production app can not have disable_auth_checks flag enabled"
        	Test:       	TestClient_UpdateAppSettings
--- FAIL: TestClient_DeleteUsers (12.00s)
    async_tasks_test.go:81: 
        	Error Trace:	async_tasks_test.go:81
        	Error:      	Should be true
        	Test:       	TestClient_DeleteUsers
        	Messages:   	task did not succeed

--- FAIL: TestClient_Devices (0.42s)
    device_test.go:23: 
        	Error Trace:	device_test.go:23
        	Error:      	Received unexpected error:
        	            	CreateDevice failed with error: "push provider "" with type "firebase" not found"
        	Test:       	TestClient_Devices
        	Messages:   	add device
--- FAIL: TestClient_SendMessage_Pending (1.01s)
    message_test.go:39: 
        	Error Trace:	message_test.go:39
        	Error:      	Received unexpected error:
        	            	SendMessage failed with error: "pending messages not enabled for this app"
        	Test:       	TestClient_SendMessage_Pending
FAIL
exit status 1
FAIL	github.com/GetStream/stream-chat-go/v6	130.451s
@dmigwi
Copy link

dmigwi commented Aug 3, 2024

I have been tinkering with this codebase and found that Unit Tests(Test run locally and verify the most fundamental bits of logic in your code) and E2E/Integration Tests(Tests verifying that your code works in a near-real life situation) are not well separated.
Running the tests with getstream test account and firebase setup leads to rate limit alerts which ought not to happen.

Screenshot 2024-08-03 at 15 02 48

The tests referenced above are E2E/Integration tests that require a more complicated firebase configuration to work.
This tests can be configured to only run when changes are detected on the methods they test using this guidelines: https://stackoverflow.com/questions/40712275/gitlab-ci-how-to-trigger-a-build-only-if-changes-happen-on-particular-set-of-f

TL;DR: Testing any method/function during unit tests, should be done in isolation. Where External configuration required, those side effects should be mocked. E2E tests should handle testing the side effects on external API use in the code.

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