func TestHasPreviousPage(t *testing.T) { resp := network.NewPharosResponse(network.PharosInstitution) assert.False(t, resp.HasPreviousPage()) link := "http://example.com" resp.Previous = &link assert.True(t, resp.HasPreviousPage()) }
func TestParamsForPreviousPage(t *testing.T) { resp := network.NewPharosResponse(network.PharosInstitution) link := "http://example.com?name=college.edu&page=6&per_page=20" resp.Previous = &link params := resp.ParamsForPreviousPage() 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 TestNewPharosResponse(t *testing.T) { for _, objType := range objectTypes { resp := network.NewPharosResponse(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.NewPharosResponse(objType) assert.Equal(t, objType, resp.ObjectType()) } }