Skip to content

Instantly share code, notes, and snippets.

@glappen
Created September 29, 2014 16:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save glappen/ca27f0d3574dff3c74b9 to your computer and use it in GitHub Desktop.
Save glappen/ca27f0d3574dff3c74b9 to your computer and use it in GitHub Desktop.
new test function
func TestCompanySpecificStats(t *testing.T) {
var before *api.InternalGetStatsResult
var after *api.InternalGetStatsResult
t.Log("Starting TestCompanySpecificStats")
anotherCompany, err := data.CreateCompany(context, "Bob's Furniture", "Bob", "bob@furniture.com")
if err != nil {
t.Fatal("Could not create another company")
}
anotherCustomer, err := data.CreateUnclaimedCustomer(context, "Greg", "greg@home.net")
if err != nil {
t.Fatal("Could not create another customer")
}
_, err = data.CreateRelationship(context, anotherCustomer.CustomerId, anotherCompany.CompanyId)
if err != nil {
t.Fatal("Could not create another relationship")
}
anotherIssue, err := data.CustomerCreateIssue(context, anotherCustomer.CustomerId, anotherCompany.CompanyId)
if err != nil {
t.Fatal("Could not create another issue")
}
super.Request(api.InternalGetStatsCode, api.InternalGetStatsParams{FromTime: 1, ToTime: data.Now(), CompanyId: anotherCompany.CompanyId}, &before)
_, err = data.CreateMessageFromCustomer(context, issue1, "Help!")
if err != nil {
t.Fatal("Could not create first message")
}
_, err = data.CreateMessageFromCustomer(context, anotherIssue, "Help!")
if err != nil {
t.Fatal("Could not create second message")
}
super.Request(api.InternalGetStatsCode, api.InternalGetStatsParams{FromTime: 1, ToTime: data.Now()}, &after)
assert(after.RepTextMessagesSentCount == before.RepTextMessagesSentCount+1)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment