Ejemplo n.º 1
0
func TestAddFilterSortToEndPointWithOnlySort(t *testing.T) {

	s := invdendpoint.NewSort()
	s.Set("name", invdendpoint.ASC)
	s.Set("age", invdendpoint.DESC)

	endPoint := "https://www.do.com"

	value := addFilterSortToEndPoint(endPoint, nil, s)

	correctValue := "https://www.do.com?sort=age+DESC%2Cname+ASC"

	if value != correctValue {
		t.Fatal("Error: resulting URL is incorrect it should be ", correctValue, " but instead got ", value)
	}

}
Ejemplo n.º 2
0
func TestAddFilterSortToEndPointWithBothValues(t *testing.T) {
	f := invdendpoint.NewFilter()
	f.Set("id", 121123)
	f.Set("address", 121123)

	s := invdendpoint.NewSort()
	s.Set("name", invdendpoint.ASC)
	s.Set("age", invdendpoint.DESC)

	endPoint := "https://www.do.com"

	value := addFilterSortToEndPoint(endPoint, f, s)

	correctValue := "https://www.do.com?filter%5Baddress%5D=121123&filter%5Bid%5D=121123&sort=age+DESC%2Cname+ASC"

	if value != correctValue {
		t.Fatal("Error: resulting URL is incorrect it should be ", correctValue, " but instead got ", value)
	}

	// endpoint2 := "https://www.do.com?"

}