Skip to content

Commit

Permalink
Added tests for pushing links
Browse files Browse the repository at this point in the history
  • Loading branch information
kariudo committed Feb 14, 2015
1 parent ca5bee7 commit 9907bcf
Showing 1 changed file with 78 additions and 0 deletions.
78 changes: 78 additions & 0 deletions gopushbullet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ func TestErrorString(t *testing.T) {
}
}

// Push - Notes

func TestSendNoteToAll(t *testing.T) {
// Use the following code in place of the mock calls to test on live api
// k, err := getKey()
Expand Down Expand Up @@ -156,6 +158,82 @@ func TestSendNoteToClientID(t *testing.T) {
}
}

// Push - Links
func TestSendLinkToAll(t *testing.T) {
mockServer, c := mockHTTP(200, "{}")
defer mockServer.Close()

err := c.SendLink("Build Test", "This is a test of gopushbullet's SendLink() function.", "http://example.com")
if err != nil {
t.Error(err)
}
}

func TestSendLinkFailurePaths(t *testing.T) {
mockServer, c := mockHTTP(401, "{}")
defer mockServer.Close()

err := c.SendLinkToTarget("channel", "testchannelpleaseignore", "Build Test", "This is a test of gopushbullet's SendLink() function.", "http://example.com")
if err == nil {
t.Error(err)
}
mockServer, c = mockHTTP(401, "invalid json")
err = c.SendLinkToTarget("channel", "testchannelpleaseignore", "Build Test", "This is a test of gopushbullet's SendLink() function.", "http://example.com")
if err == nil {
t.Error(err)
}
}

func TestSendLinkToDevice(t *testing.T) {
mockServer, c := mockHTTP(200, "{}")
defer mockServer.Close()

err := c.SendLinkToTarget("device", "_deviceid_", "Build Test", "This is a test of gopushbullet's SendLink() function.", "http://example.com")
if err != nil {
t.Error(err)
}
}

func TestSendLinkInvalidTarget(t *testing.T) {
mockServer, c := mockHTTP(200, "{}")
defer mockServer.Close()

err := c.SendLinkToTarget("waffles", "bacon", "Build Test", "This is a test of gopushbullet's SendLink() function.", "http://example.com")
if err == nil {
t.Error(err)
}
}

func TestSendLinkToChannel(t *testing.T) {
mockServer, c := mockHTTP(200, "{}")
defer mockServer.Close()

err := c.SendLinkToTarget("channel", "testchannelpleaseignore", "Build Test", "This is a test of gopushbullet's SendLink() function.", "http://example.com")
if err != nil {
t.Error(err)
}
}

func TestSendLinkToEmail(t *testing.T) {
mockServer, c := mockHTTP(200, "{}")
defer mockServer.Close()

err := c.SendLinkToTarget("email", "kariudo@gmail.com", "Build Test", "This is a test of gopushbullet's SendLink() function.", "http://example.com")
if err != nil {
t.Error(err)
}
}

func TestSendLinkToClientID(t *testing.T) {
mockServer, c := mockHTTP(200, "{}")
defer mockServer.Close()

err := c.SendLinkToTarget("client", "_clientid_", "Build Test", "This is a test of gopushbullet's SendLink() function.", "http://example.com")
if err != nil {
t.Error(err)
}
}

func TestGetDevices(t *testing.T) {
k, err := getKey()
if err != nil {
Expand Down

0 comments on commit 9907bcf

Please sign in to comment.