go-sdk icon indicating copy to clipboard operation
go-sdk copied to clipboard

[ENHANCEMENT] Make it easier to test from the outside?

Open rlalaska opened this issue 9 months ago • 0 comments

Description

This library is difficult to test because instead of returning pointers to structs, the sdk returns structs as values forcing the consumer to cast it to a pointer in order to call the necessary methods on the receiver (as the receiver is a pointer). The difficulty comes in when one wants to mock these calls out for testing purpose in their own application as a value struct can not be cast to an interface, only pointers. I wonder if its possible to add additional constructor methods that return the pointer. Thoughts?

Benefits

Easier testability from the consumers perscpective.

Detail

No response

Examples

Example:

func (o *OptimizelyClient) CreateUserContextP(userID string, attributes map[string]interface{}) *OptimizelyUserContext {
	return newOptimizelyUserContextP(o, userID, attributes, nil)
}

Risks/Downsides

No response

rlalaska avatar May 15 '25 19:05 rlalaska