github.com/crosbymichael/octokat@v0.0.0-20160826194511-076a32289ed5/root_test.go (about)

     1  package octokat
     2  
     3  import (
     4  	"github.com/bmizerany/assert"
     5  	"net/http"
     6  	"testing"
     7  )
     8  
     9  func TestRoot(t *testing.T) {
    10  	setup()
    11  	defer tearDown()
    12  
    13  	mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
    14  		testMethod(t, r, "GET")
    15  		respondWith(w, loadFixture("root.json"))
    16  	})
    17  
    18  	root, _ := client.Root(nil)
    19  	assert.T(t, root.client != nil)
    20  	assert.Equal(t, 27, len(root.links))
    21  
    22  	repoLink := root.Rel("repository")
    23  	assert.T(t, repoLink.client != nil)
    24  	assert.Equal(t, "repository", repoLink.Rel)
    25  	assert.Equal(t, "https://api.github.com/repos/{owner}/{repo}", repoLink.Href)
    26  }
    27  
    28  func TestParseRelNameFromURL(t *testing.T) {
    29  	assert.Equal(t, "repository", parseRelNameFromURL("repository_url"))
    30  	assert.Equal(t, "public_gists", parseRelNameFromURL("public_gists_url"))
    31  }