filmov
tv
Interfaces 101 : Testing with a Mock Interface

Показать описание
Episode 8! - Watch and learn how to mock server responses for unit tests. -- In this video, Miki will build an API client type for a web service. The type will have a method called `Health` that:
- Performs an HTTP request to a URL.
- Returns an error depending on the response code received from the server.
Miki will then proceed by writing unit tests to verify if the client is working as intended. In lieu of a real server, Miki will create a new type that implements the `http.RoundTripper` interface and use it as the request’s transport during testing to manually specify the response code returned.
Things you will learn in this video
- Perform an HTTP request with the Go STD library.
- Mock an HTTP response for unit tests.
--
Which aspects of your tests do you mock by taking advantage of Go interfaces?
Comment below or tweet us on twitter & let us know, we want to hear from you! ~ If you found this video helpful, hit that like button & subscribe for more content like this.
--
Other Links:
- Performs an HTTP request to a URL.
- Returns an error depending on the response code received from the server.
Miki will then proceed by writing unit tests to verify if the client is working as intended. In lieu of a real server, Miki will create a new type that implements the `http.RoundTripper` interface and use it as the request’s transport during testing to manually specify the response code returned.
Things you will learn in this video
- Perform an HTTP request with the Go STD library.
- Mock an HTTP response for unit tests.
--
Which aspects of your tests do you mock by taking advantage of Go interfaces?
Comment below or tweet us on twitter & let us know, we want to hear from you! ~ If you found this video helpful, hit that like button & subscribe for more content like this.
--
Other Links: