Description
To improve the testability of the basic_query function in the ChatGPT module, we need to refactor it to accept a ChatGPTClient object. This will enable the use of a mock client during testing, while the actual client will be used during normal usage.
Tasks
-
Create a MockChatGPTClient struct that implements the ChatGPTClient trait. The mock client should return pre-defined responses for testing purposes instead of making actual API calls.
-
Update the basic_query function signature to accept a ChatGPTClient object as a parameter.
-
Update the test module to use the MockChatGPTClient for testing the basic_query function.
-
Update the main.rs file to pass the default client when calling the basic_query function.
Acceptance Criteria
- The
basic_query function accepts a ChatGPTClient object as a parameter.
- A
MockChatGPTClient struct is implemented for testing purposes.
- A test for
basic_query function is added that uses the MockChatGPTClient.
- The
main.rs file is updated to pass the default client when calling basic_query.
Description
To improve the testability of the
basic_queryfunction in theChatGPTmodule, we need to refactor it to accept aChatGPTClientobject. This will enable the use of a mock client during testing, while the actual client will be used during normal usage.Tasks
Create a
MockChatGPTClientstruct that implements theChatGPTClienttrait. The mock client should return pre-defined responses for testing purposes instead of making actual API calls.Update the
basic_queryfunction signature to accept aChatGPTClientobject as a parameter.Update the test module to use the
MockChatGPTClientfor testing thebasic_queryfunction.Update the
main.rsfile to pass the default client when calling thebasic_queryfunction.Acceptance Criteria
basic_queryfunction accepts aChatGPTClientobject as a parameter.MockChatGPTClientstruct is implemented for testing purposes.basic_queryfunction is added that uses theMockChatGPTClient.main.rsfile is updated to pass the default client when callingbasic_query.