Skip to content

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

Description

@rlalaska

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

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions