jeudi 23 juillet 2020

Mocking in golang

I am trying to write unit tests for a .go file and one of the functions in that file that I want to test (let's call it isMyDesiredType()) takes a map[string]interface{} and checks [types_map].(map[string]interface{}) to get the type and then checks that type against my desired type, returning a boolean if it matches.

I am wondering if anyone has any suggestions for how to mock map[string]interface{} in my test file so that I can pass both an empty map[string]interface{} and a map[string]interface{} that is not empty (for both a type that matches my desired type and a case where it does not match my desired type) to the function that I want to test.

Thank you in advance for any guidance!

Aucun commentaire:

Enregistrer un commentaire