Skip to content

Commit

Permalink
refactor: replace litter with cmp (#2162)
Browse files Browse the repository at this point in the history
remove litter from go.mod

Signed-off-by: Sandor Szücs <[email protected]>

Signed-off-by: Sandor Szücs <[email protected]>
  • Loading branch information
szuecs authored Nov 30, 2022
1 parent 8f042db commit cbc8789
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 32 deletions.
9 changes: 3 additions & 6 deletions dataclients/routestring/string_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package routestring

import (
"reflect"
"testing"

"github.com/sanity-io/litter"
"github.com/google/go-cmp/cmp"
"github.com/zalando/skipper/eskip"
)

Expand Down Expand Up @@ -101,10 +100,8 @@ func TestRouteString(t *testing.T) {
r = nil
}

if !reflect.DeepEqual(r, test.expected) {
t.Error("invalid routes received")
t.Log("got: ", litter.Sdump(r))
t.Log("expected:", litter.Sdump(test.expected))
if !cmp.Equal(r, test.expected) {
t.Errorf("invalid routes received\n %s", cmp.Diff(r, test.expected))
}
})
}
Expand Down
25 changes: 11 additions & 14 deletions eskip/eskip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"testing"

"github.com/google/go-cmp/cmp"
"github.com/sanity-io/litter"
)

func checkItems(t *testing.T, message string, l, lenExpected int, checkItem func(int) bool) bool {
Expand Down Expand Up @@ -372,10 +371,8 @@ func TestPredicateParsing(t *testing.T) {
return
}

if !reflect.DeepEqual(p, test.expected) {
t.Error("invalid parse result")
t.Log("got:", litter.Sdump(p))
t.Log("expected:", litter.Sdump(test.expected))
if !cmp.Equal(p, test.expected) {
t.Errorf("invalid parse result:\n%s", cmp.Diff(p, test.expected))
}
})
}
Expand Down Expand Up @@ -634,7 +631,7 @@ func TestClonePreProcessor(t *testing.T) {
repl: "HostAny($1)",
},
routes: `r0: Host("www[.]example[.]org") -> status(201) -> <shunt>;`,
want: `r0: Host("www[.]example[.]org") -> status(201) -> <shunt>;
want: `r0: Host("www[.]example[.]org") -> status(201) -> <shunt>;
clone_r0: HostAny("www[.]example[.]org") -> status(201) -> <shunt>;`,
},
{
Expand All @@ -653,7 +650,7 @@ func TestClonePreProcessor(t *testing.T) {
repl: "ClientIP($1)",
},
routes: `r1: Source("1.2.3.4/26") -> status(201) -> <shunt>;`,
want: `r1: Source("1.2.3.4/26") -> status(201) -> <shunt>;
want: `r1: Source("1.2.3.4/26") -> status(201) -> <shunt>;
clone_r1: ClientIP("1.2.3.4/26") -> status(201) -> <shunt>;`,
},
{
Expand All @@ -662,11 +659,11 @@ func TestClonePreProcessor(t *testing.T) {
reg: regexp.MustCompile("Source[(](.*)[)]"),
repl: "ClientIP($1)",
},
routes: `r0: Host("www[.]example[.]org") -> status(201) -> <shunt>;
routes: `r0: Host("www[.]example[.]org") -> status(201) -> <shunt>;
r1: Source("1.2.3.4/26") -> status(201) -> <shunt>;`,

want: `r0: Host("www[.]example[.]org") -> status(201) -> <shunt>;
r1: Source("1.2.3.4/26") -> status(201) -> <shunt>;
want: `r0: Host("www[.]example[.]org") -> status(201) -> <shunt>;
r1: Source("1.2.3.4/26") -> status(201) -> <shunt>;
clone_r1: ClientIP("1.2.3.4/26") -> status(201) -> <shunt>;`,
},
{
Expand All @@ -676,7 +673,7 @@ func TestClonePreProcessor(t *testing.T) {
repl: "ClientIP($1)",
},
routes: `rn: Source("1.2.3.4/26", "10.5.5.0/24") -> status(201) -> <shunt>;`,
want: `rn: Source("1.2.3.4/26", "10.5.5.0/24") -> status(201) -> <shunt>;
want: `rn: Source("1.2.3.4/26", "10.5.5.0/24") -> status(201) -> <shunt>;
clone_rn: ClientIP("1.2.3.4/26", "10.5.5.0/24") -> status(201) -> <shunt>;`,
},
{
Expand All @@ -687,8 +684,8 @@ func TestClonePreProcessor(t *testing.T) {
},
routes: `r0: Host("www[.]example[.]org") -> status(201) -> <shunt>;
rn: Source("1.2.3.4/26", "10.5.5.0/24") -> status(201) -> <shunt>;`,
want: `r0: Host("www[.]example[.]org") -> status(201) -> <shunt>;
rn: Source("1.2.3.4/26", "10.5.5.0/24") -> status(201) -> <shunt>;
want: `r0: Host("www[.]example[.]org") -> status(201) -> <shunt>;
rn: Source("1.2.3.4/26", "10.5.5.0/24") -> status(201) -> <shunt>;
clone_rn: ClientIP("1.2.3.4/26", "10.5.5.0/24") -> status(201) -> <shunt>;`,
},
{
Expand All @@ -698,7 +695,7 @@ func TestClonePreProcessor(t *testing.T) {
repl: "normalRequestLatency($1)",
},
routes: `r1_filter: Source("1.2.3.4/26") -> uniformRequestLatency("100ms", "10ms") -> status(201) -> <shunt>;`,
want: `r1_filter: Source("1.2.3.4/26") -> uniformRequestLatency("100ms", "10ms") -> status(201) -> <shunt>;
want: `r1_filter: Source("1.2.3.4/26") -> uniformRequestLatency("100ms", "10ms") -> status(201) -> <shunt>;
clone_r1_filter: Source("1.2.3.4/26") -> normalRequestLatency("100ms", "10ms") -> status(201) -> <shunt>;`,
}} {
t.Run(tt.name, func(t *testing.T) {
Expand Down
9 changes: 3 additions & 6 deletions eskipfile/remote_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ import (
"net"
"net/http"
"net/http/httptest"
"reflect"
"testing"
"time"

"github.com/sanity-io/litter"
"github.com/google/go-cmp/cmp"
"github.com/zalando/skipper/eskip"
)

Expand Down Expand Up @@ -111,10 +110,8 @@ func TestLoadAll(t *testing.T) {
r = nil
}

if !reflect.DeepEqual(r, test.expected) {
t.Error("invalid routes received")
t.Log("got: ", litter.Sdump(r))
t.Log("expected:", litter.Sdump(test.expected))
if !cmp.Equal(r, test.expected) {
t.Errorf("invalid routes received\n%s", cmp.Diff(r, test.expected))
}
})
}
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ require (
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.11.1
github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a
github.com/sanity-io/litter v1.5.2
github.com/sarslanhan/cronmask v0.0.0-20190709075623-766eca24d011
github.com/sirupsen/logrus v1.8.1
github.com/sony/gobreaker v0.5.0
Expand Down
5 changes: 0 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,6 @@ github.com/d2g/dhcp4 v0.0.0-20170904100407-a1d1b6c41b1c/go.mod h1:Ct2BUK8SB0YC1S
github.com/d2g/dhcp4client v1.0.0/go.mod h1:j0hNfjhrt2SxUOw55nL0ATM/z4Yt3t2Kd1mW34z5W5s=
github.com/d2g/dhcp4server v0.0.0-20181031114812-7d4a0a7f59a5/go.mod h1:Eo87+Kg/IX2hfWJfwxMzLyuSZyxSoAug2nGa1G2QAi8=
github.com/d2g/hardwareaddr v0.0.0-20190221164911-e7d9fbe030e4/go.mod h1:bMl4RjIciD2oAxI7DmWRx6gbeqrkoLqv3MV0vzNad+I=
github.com/davecgh/go-spew v0.0.0-20161028175848-04cdfd42973b/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down Expand Up @@ -699,7 +698,6 @@ github.com/pkg/errors v0.8.1-0.20171018195549-f15c970de5b7/go.mod h1:bwawxfHBFNV
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pquerna/cachecontrol v0.0.0-20171018203845-0dec1b30a021 h1:0XM1XL/OFFJjXsYXlG30spTkV/E9+gmd5GD1w2HE8xM=
Expand Down Expand Up @@ -749,8 +747,6 @@ github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6L
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/safchain/ethtool v0.0.0-20190326074333-42ed695e3de8/go.mod h1:Z0q5wiBQGYcxhMZ6gUqHn6pYNLypFAvaL3UvgZLR0U4=
github.com/sanity-io/litter v1.5.2 h1:AnC8s9BMORWH5a4atZ4D6FPVvKGzHcnc5/IVTa87myw=
github.com/sanity-io/litter v1.5.2/go.mod h1:5Z71SvaYy5kcGtyglXOC9rrUi3c1E8CamFWjQsazTh0=
github.com/sarslanhan/cronmask v0.0.0-20190709075623-766eca24d011 h1:S5j3KTsiGwmQSEJJBp0iIG87CDBCGCwbYLmVv8L/nuE=
github.com/sarslanhan/cronmask v0.0.0-20190709075623-766eca24d011/go.mod h1:NmI1tg7wwsf1hF6G5EtyGCrtNKsH2RIdYYoJa7GsnP8=
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
Expand Down Expand Up @@ -803,7 +799,6 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48=
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
github.com/stretchr/testify v0.0.0-20161117074351-18a02ba4a312/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v0.0.0-20180303142811-b89eecf5ca5d/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
Expand Down

0 comments on commit cbc8789

Please sign in to comment.