dukex / mixpanel

Golang Mixpanel Client
MIT License
61 stars 33 forks source link

Added mocked implementation for use in unit tests #1

Closed mr-andreas closed 8 years ago

mr-andreas commented 8 years ago

Hi!

I've changed the Mixpanel struct to be an interface and added a mock implementation in addition to the current real implementation. This makes it easy to test code which uses mixpanel:

var client mixpanel.Mixpanel = mixpanel.NewMock()

people = client.Identify("1")
people.Update("$set", map[string]interface{}{
    "custom_field": "cool!",
})

// client.People now holds the tracked data

Also, functions now only return a single error and not an HTTP response, making error handling easier.

mr-andreas commented 8 years ago

Ok, so this PR has gotten quite huge, the library has changed in many ways. Do you want to merge this, or would you rather see that we just keep our own fork?

dukex commented 8 years ago

Good job @yoshiyaka, sorry the delay