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

AG-22 - Add Agent Tests #58

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open

AG-22 - Add Agent Tests #58

wants to merge 26 commits into from

Conversation

SammyOina
Copy link
Contributor

What does this do?

Adds tests to agent

Which issue(s) does this PR fix/relate to?

Resolves #22

List any changes that modify/break current functionality

Have you included tests for your changes?

Did you document any new/modified functionality?

Notes

Add tests for NewHeartbeat and Update functions
```

This commit adds tests for the `NewHeartbeat` and `Update` functions in the `agent` package. The `NewHeartbeat` test checks if the `NewHeartbeat` function correctly initializes a new heartbeat with the given name, service type, and interval. It also verifies the initial status and info of the heartbeat.

Signed-off-by: SammyOina <[email protected]>
@SammyOina SammyOina marked this pull request as draft September 22, 2023 08:27
Signed-off-by: SammyOina <[email protected]>
Fix error when writing to TOML file

The commit fixes an error that occurs when writing to a TOML file.
The error is wrapped with a custom error message.
This ensures that the error is properly handled and provides more
context to the developer.

The commit also includes changes to the import statements in the
bootstrap.go file.

Signed-off-by: SammyOina <[email protected]>
The commit fixes error handling in the bootstrap_test.go file by checking for an error when writing the response body. This ensures that any errors are properly handled and reported.

Signed-off-by: SammyOina <[email protected]>
The `Info()` method in the `Heartbeat` interface was not thread-safe,
which could lead to a race condition when accessing the `info` field.
To fix this issue, a mutex was added to protect the access to `info`
and ensure thread safety. The `Info()` method now locks the mutex
before accessing `info` and unlocks it before returning the value.
Additionally, a new `Close()` method was added to stop the heartbeat
ticker when it is no longer needed.

Signed-off-by: SammyOina <[email protected]>
The commit fixes error handling in agent/config.go
by adding more specific error variables and updating
the error messages. This improves the clarity and
readability of the codebase.

Signed-off-by: SammyOina <[email protected]>
Signed-off-by: SammyOina <[email protected]>
Signed-off-by: SammyOina <[email protected]>
Signed-off-by: SammyOina <[email protected]>
Signed-off-by: SammyOina <[email protected]>
Signed-off-by: SammyOina <[email protected]>
Signed-off-by: SammyOina <[email protected]>
Signed-off-by: SammyOina <[email protected]>
Signed-off-by: SammyOina <[email protected]>
Signed-off-by: SammyOina <[email protected]>
Refactor build workflow

The build22.yml file has been deleted. This commit removes the build22.yml file, which was used to create and publish a Docker image. The file is no longer needed as it is no longer being used in the project.

Signed-off-by: SammyOina <[email protected]>
This commit adds a new test for the PushOperation function in the edgex package. The test creates a mock HTTP server and checks the HTTP request method, URL, and request body. The test ensures that the function correctly handles the POST request with the expected URL and request body.

Signed-off-by: SammyOina <[email protected]>
This commit adds tests for the conn package. The tests cover various scenarios and ensure the functionality of the package is working as expected.

Signed-off-by: SammyOina <[email protected]>
The commit fixes a bug in the client_test.go file where the expected response was not being properly set. The bug caused the test to fail. The fix ensures that the expected response is correctly set and the test passes as expected.

Signed-off-by: SammyOina <[email protected]>
The commit fixes error handling in main.go and endpoints_test.go.
It ensures that the server is properly shutdown and logs any errors
that occur during the shutdown process.

Signed-off-by: SammyOina <[email protected]>
@SammyOina SammyOina marked this pull request as ready for review September 28, 2023 10:30
.github/workflows/test.yml Outdated Show resolved Hide resolved
.github/workflows/test.yml Outdated Show resolved Hide resolved
.github/workflows/test.yml Outdated Show resolved Hide resolved
.github/workflows/test.yml Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
docker/Dockerfile Outdated Show resolved Hide resolved
docker/Dockerfile Outdated Show resolved Hide resolved
pkg/bootstrap/bootstrap_test.go Outdated Show resolved Hide resolved
pkg/edgex/client_test.go Outdated Show resolved Hide resolved
pkg/edgex/client_test.go Outdated Show resolved Hide resolved
Signed-off-by: SammyOina <[email protected]>
The Docker image tag and file path in the Makefile and Dockerfile have been fixed to use the correct repository name "Mainflux" instead of "sammyoina". This ensures that the Docker images are tagged and pushed to the correct repository. Additionally, the file path in the Dockerfile has been updated to correctly move the built executable to the desired location.

Signed-off-by: SammyOina <[email protected]>
Signed-off-by: SammyOina <[email protected]>
The Docker image tag in the Makefile was updated to use lowercase "mainflux" instead of "Mainflux". This ensures consistency with the naming convention used for the Docker images.

Signed-off-by: SammyOina <[email protected]>
rodneyosodo
rodneyosodo previously approved these changes Sep 28, 2023
Copy link
Member

@rodneyosodo rodneyosodo left a comment

Choose a reason for hiding this comment

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

LGTM

pkg/bootstrap/bootstrap_test.go Outdated Show resolved Hide resolved
pkg/terminal/terminal_test.go Outdated Show resolved Hide resolved
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

Successfully merging this pull request may close these issues.

Agent needs tests
3 participants