Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: DRYing, device.name cleanup * chore: clippy * cleanup: remove device.sku * cleanup: device.sku * cleanup: device.screenresolution * cleanup: device.network * cleanup: device.make * chore: clippy * pr: metrics_state cleanup * cleanup: hygiene * cleanup: tests, hygiene * debt: adding thunder plugin test * chore: more review * This is a set of unit tests for a `WorkflowBroker` class in Rust. Here's a breakdown of what each test does: **Test 1: Successful workflow execution** * Creates a `MockEndpointBrokerState` instance to simulate responses from an endpoint broker. * Sets up a response for a sub-method that returns a successful result. * Creates a `BrokerRequest` instance with a rule that has one source (the sub-method). * Calls the `run_workflow` method on the `WorkflowBroker` instance, passing in the `BrokerRequest` and `MockEndpointBrokerState`. * Asserts that the result is a successful response with the expected result. **Test 2: Sub-broker failure** * Creates a `MockEndpointBrokerState` instance to simulate responses from an endpoint broker. * Sets up a response for a sub-method that returns an error result. * Creates a `BrokerRequest` instance with a rule that has two sources (the sub-method and another method). * Calls the `run_workflow` method on the `WorkflowBroker` instance, passing in the `BrokerRequest` and `MockEndpointBrokerState`. * Asserts that the result is an error response. **Test 3: Empty sources** * Creates a `MockEndpointBrokerState` instance to simulate responses from an endpoint broker. * Creates a `BrokerRequest` instance with a rule that has no sources. * Calls the `run_workflow` method on the `WorkflowBroker` instance, passing in the `BrokerRequest` and `MockEndpointBrokerState`. * Asserts that the result is a successful response with an empty object. **Test 4: Merging parameters** * Creates a `MockEndpointBrokerState` instance to simulate responses from an endpoint broker. * Sets up a response for a sub-method that returns a result with specific parameters. * Creates a `BrokerRequest` instance with global and source-specific parameters. * Calls the `run_workflow` method on the `WorkflowBroker` instance, passing in the `BrokerRequest` and `MockEndpointBrokerState`. * Asserts that the result is a successful response with the expected merged parameters. Overall, these tests cover various scenarios for the `WorkflowBroker` class, including successful workflow execution, sub-broker failure, empty sources, and merging parameters. * It looks like you have a set of test cases for a `WorkflowBroker` module. I'll help you identify the main points and provide some suggestions. **Main Points:** 1. The tests cover various scenarios, such as: * Successful execution with multiple sources * Failing source (returns an error) * Empty sources * Merging parameters from global and source-specific levels 2. The tests use a `MockEndpointBrokerState` object to simulate the behavior of an endpoint broker. 3. The tests verify the correctness of the `WorkflowBroker` module by checking the returned values against expected results. **Suggestions:** 1. **Consistent naming conventions**: Some test function names (e.g., `test_run_workflow_multiple_sources`) don't follow a consistent naming convention (e.g., `test_run_workflow_with_failing_source`). Consider using a consistent naming scheme throughout. 2. **Clear error handling**: In the `test_run_workflow_source_failure` test, you're checking if the result is an instance of `Error`. Consider making this more explicit by creating a custom error type for your module and checking against that instead. 3. **Consider adding more tests**: While the existing tests cover some scenarios, there might be other edge cases or variations that are not tested yet (e.g., what happens when multiple sources fail?). 4. **Use a testing framework**: If you're using a testing framework like `cargo-test` or `rust-test`, consider leveraging its features to make your tests more concise and expressive. 5. **Document the test cases**: Consider adding comments or docstrings to explain the purpose of each test case, making it easier for others (or yourself) to understand the reasoning behind these tests. Let me know if you'd like me to elaborate on any of these points! * fix: Add corrected test cases for WorkflowBroker. * fix: Add default implementations to structs. * fix: revert bad tests * chore: merge * fix: device.hdcp unwrap * hygiene: war on dots, remove device unwraps * chore: merge from upstream
- Loading branch information