Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
rlalaska opened this issue May 15, 2025 · 0 comments
Open

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

rlalaska opened this issue May 15, 2025 · 0 comments

Comments

@rlalaska
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant