Skip to content

Commit

Permalink
Test to increase coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
henrod committed Mar 8, 2017
1 parent 3698f43 commit 974ee1e
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions models/offer_template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,28 @@ var _ = Describe("Offer Template Models", func() {
Expect(err.Error()).To(Equal("sql: database is closed"))
db = oldDB // avoid errors in after each
})

It("should not create new offer template if inserting with repeated key", func() {
//Given
offerTemplate := &models.OfferTemplate{
Name: "new-template",
Key: "471c730b-b8ed-4caa-a245-f46822914c8c",
ProductID: "com.tfg.example",
GameID: "unique-offers-game",
Contents: dat.JSON([]byte(`{"gems": 5, "gold": 100}`)),
Period: dat.JSON([]byte(`{"every": "10m"}`)),
Frequency: dat.JSON([]byte(`{"every": "24h"}`)),
Trigger: dat.JSON([]byte(`{"from": 1487280506875}`)),
Placement: "popup",
}

//When
_, err := models.InsertOfferTemplate(db, offerTemplate, true, nil)

//Then
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(Equal("OfferTemplate could not be saved due to: There is another enabled offer template with key 471c730b-b8ed-4caa-a245-f46822914c8c"))
})
})

Describe("List offer templates", func() {
Expand Down

0 comments on commit 974ee1e

Please sign in to comment.