xkcd-go

Golang tool to read latest, random, or a specific xkcd comic (and download it too).
git clone http://git.hanabi.in/repos/xkcd-go.git
Log | Files | Refs | README | LICENSE

detect-api_test.go (509B)


      1 package xkcd
      2 
      3 import (
      4 	"fmt"
      5 	"testing"
      6 )
      7 
      8 func TestLatestAPI(t *testing.T) {
      9 	expected := "https://xkcd.com/info.0.json"
     10 	received := detectAPI(0)
     11 	if expected != received {
     12 		msg := fmt.Sprintf("Expected `%s', received `%s'.\n", expected, received)
     13 		t.Error(msg)
     14 	}
     15 }
     16 
     17 func TestSpecificAPI(t *testing.T) {
     18 	expected := "https://xkcd.com/541/info.0.json"
     19 	received := detectAPI(541)
     20 	if expected != received {
     21 		msg := fmt.Sprintf("Expected `%s', received `%s'.\n", expected, received)
     22 		t.Error(msg)
     23 	}
     24 }