Guidance on techniques that can help me write a comprehensive test for my go library.

284 views
Skip to first unread message

Ai Readone

unread,
Jun 5, 2024, 9:41:03 AMJun 5
to golan...@googlegroups.com
Hello Everyone,

I am currently writing a go library that Integrates various Google cloud services.

The aim of the library is to eliminate duplicate implementations across various services of the same software.


I am having challenges on how to write a comprehensive test for my library, the main challenges are coming from testing function and methods that performs remote call to Google cloud APIs

I want to be able to mock every function in my library.

I am familiar with majorly table-testing technique but I am open to suggestions that requires me to learn new technologies too.

Thanks in advance for your time and help.

Marcello H

unread,
Jun 6, 2024, 2:27:53 AMJun 6
to golang-nuts
Normally, the way to use the functions/methods of the external library is by having an interface with all the function definitions.

Then you can generate a mock that offers the same functionality.
With such a mock, you can give all kinds of results back to the caller.

Do you have your project in a public GIT?

Op woensdag 5 juni 2024 om 15:41:03 UTC+2 schreef Ai Readone:

Jeremy French

unread,
Jun 6, 2024, 7:17:30 AMJun 6
to golang-nuts
This:

> "I want to be able to mock every function in my library."
is a bit confusing. Normally, you want to mock the functions that your library calls, not your own library functions.

Other than that, this seems pretty doable.. Can you give some more clarification as to what aspect is giving you trouble?

Guilherme Henrique

unread,
Jun 7, 2024, 9:26:35 AMJun 7
to golang-nuts
You want to make a mock of the Google API calls, the same ones you use in your project, and that's it?

Amnon

unread,
Jun 8, 2024, 2:56:27 AMJun 8
to golang-nuts
Reply all
Reply to author
Forward
0 new messages