Skip to content

Refactor basic_query to support testing with a mock client #41

@DieHard073055

Description

@DieHard073055

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

  1. 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.

  2. Update the basic_query function signature to accept a ChatGPTClient object as a parameter.

  3. Update the test module to use the MockChatGPTClient for testing the basic_query function.

  4. 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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions