Skip to content

Testing for Contributors

Sean Reeise edited this page Jun 1, 2023 · 4 revisions

Testing PR's

Github Actions Causes Tests Failures

The tests are using a sanboxed environment for testing against Microsoft graph and Azure Active Directory. To run the complete tests you will actually need credentials that are from the Active Directory applications in this sandbox environment. However, we cannot just hand these out as it is a security issue.

Because of this, the GitHub actions will only pass the tests when run on pull requests created by the maintainer. There is only one test that actually causes the failure when running cargo test without these credentials and you will typically see the failure saying something in relation to being unable to get an access token.

The testing is an area that needs work to make it easier for every contributor to test their own changes. However, you can still test any logic you have outside of actual calls to the sandbox environment.

Other ways to test

  • If your in the repo itself, you can create the file examples/test.rs in order to run your own manual tests. This file is in the .gitignore and so will not be pushed to GitHub.
  • You can also create another cargo lib or binary locally and use a local copy of graph-rs-sdk as a depenency to manually test. If you are able to get an access token, you can use your local copy of graph-rs-sdk and test the client itself by calling api's and verifying if changes. This may be helpful in scenarios where your changing code directly related to the ecosystem that deals with client impl such as graph-http or the client api implementations themselves.
  • There are still many tests that do not require credentials for the sandbox environment. Most of those are ones that are testing the functionality of the client and the verification of creating the url path and query params for various requests. These tests are great in catching issues with how the url path is built which is using the handlebars crate internally to format the path. These types of tests and any other logic tests that do not need to call the sandbox environment are extremely helpful.