-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Add a Mocked Server for Testing #30
Comments
@RobotSail Do you need any help on this? |
Hi @vimitdhawan, we merged #31 last year, and I haven't touched the others once since. If you wanted to contribute some tests for these other points, that would be amazing. |
The testing of the file is not done yet, can I contribute a bit to this? |
And I think it is unreasonable to put all the tests in the api_test file, and the functions of the same nature should be put in one file |
@RobotSail Hi. Client should be an interface to a
This is untested but should be the general format. I'd be happy to try to take it on, it would just be a pretty large refactor but would make it easier for users (like me) to test the Client. |
@drkennetz, the approach you are talking about would generally be correct if there were some business logic in |
After some further thought, do we really even need the rest of these tests? |
The goal of mock's is never to test an API call, it is to ensure that changes in internal software don't break your code. They provide fast iteration if you ever decide to change your code, and they provide consistent results. I don't understand what you mean by saying that "you don't get it tested if you mock it". Yeah, you don't test that you actually make an API call to openai, but you test the method takes in and puts out data correctly. There is a lot of software that is "just an API call" and contains nothing except a Get request to a database, and that software should absolutely be wrapped in tests. It is also core to the business. Arguably, it doesn't make sense to make "actual" api requests to a third party as you have no control over them changing the API, there is no way you can guarantee consistent results, and it will be abundantly apparent to you and everybody else if the API stops working like it used to. All you're really checking by getting an actual response is that you can connect to the API. |
@drkennetz got it, thank you! From your example above, it appears that you've proposed to mock a client like this https://github.com/sashabaranov/go-gpt3/blob/39ca4e94882215d59857cd8791c12082edec2c97/engines.go#L24 which would defeat the purpose of testing the business logic in the client. From your last message, I understand that you propose to mock Would love to merge your PR implementing that! 🙌🏻 |
Sorry for the lack of clarity in my original post! I'd be happy to do that. Maybe I'll start with a small one as an example, and if we're happy with it I can implement across the board 👍 |
refactoring tests with mock servers (sashabaranov#30) (sashabaranov#356)
@sashabaranov Mock testing of all OpenAI APIs was implemented with a pull request |
Fixed #356 |
Based on a request from #27, we should introduce a mocked server which tests that values are correctly sent by
go-gpt3
and received by the server, as well as the ability for the client to receive data from the server.This can help us to quickly iterate on tests without spending any OpenAI credits.
We need the following to complete this task
The text was updated successfully, but these errors were encountered: