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()) }
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")) }
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) } }
func TestObjectType(t *testing.T) { for _, objType := range objectTypes { resp := network.NewDPNResponse(objType) assert.Equal(t, objType, resp.ObjectType()) } }