Ejemplo n.º 1
0
func TestHasPreviousPage(t *testing.T) {
	resp := network.NewDPNResponse(dpn.DPNTypeNode)
	assert.False(t, resp.HasPreviousPage())
	link := "http://example.com"
	resp.Previous = &link
	assert.True(t, resp.HasPreviousPage())
}
Ejemplo n.º 2
0
func TestParamsForNextPage(t *testing.T) {
	resp := network.NewDPNResponse(dpn.DPNTypeNode)
	link := "http://example.com?name=college.edu&page=6&per_page=20"
	resp.Next = &link
	params := resp.ParamsForNextPage()
	assert.Equal(t, 3, len(params))
	assert.Equal(t, "college.edu", params.Get("name"))
	assert.Equal(t, "6", params.Get("page"))
	assert.Equal(t, "20", params.Get("per_page"))
}
Ejemplo n.º 3
0
func TestNewDPNResponse(t *testing.T) {
	for _, objType := range objectTypes {
		resp := network.NewDPNResponse(objType)
		assert.NotNil(t, resp)
		assert.Equal(t, objType, resp.ObjectType())
		assert.Equal(t, 0, resp.Count)
		assert.Nil(t, resp.Next)
		assert.Nil(t, resp.Previous)
	}
}
Ejemplo n.º 4
0
func TestObjectType(t *testing.T) {
	for _, objType := range objectTypes {
		resp := network.NewDPNResponse(objType)
		assert.Equal(t, objType, resp.ObjectType())
	}
}