'Mocking proto.Message in Go

I wrote a function that takes a list of proto.Message objects. Looking at the documentation, it seems like proto.Message wraps protoreflect.ProtoMessage which contains a single function, ProtoReflect() Message. Looking at the documentation for Message, it implements a number of other functions that return types referenced by the protoreflect package.

It seems that attempting to create a mock proto.Message would be a lot more work that it's worth but I don't want to go through the whole process of creating a protobuf file, compiling it and referencing it just for unit testing.

Is there another way I can create a mock proto.Message object?



Solution 1:[1]

You need to keep the API-key away from the Angular frontend. If you have an dotnet core backend, create a controller there that wraps your call to the API (with for example HttpClient) and returns the response.

Angular <-> backend <-> API 
                    key

Instead of

Angular <-> API 
        key

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 BobbyTables