-
Notifications
You must be signed in to change notification settings - Fork 160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove goconvey from go/lib/hpkt #3039
Remove goconvey from go/lib/hpkt #3039
Conversation
e2171c2
to
df94d3a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 3 of 3 files at r1.
Reviewable status: all files reviewed, 8 unresolved discussions (waiting on @karampok)
go/lib/hpkt/extension_test.go, line 32 at r1 (raw file):
ExpectedOutputHBH []common.Extension ExpectedOutputE2E []common.Extension ExpectedError bool
use require.ErrorAssertionFunc
instead
i.e.
...
ExpectedOutputE2E []common.Extension
Assertion require.ErrorAssertionFunc
}
and replace ExpectedError: true
with require.Error
and ExpectedError: false
with require.NoError
see how it is used in comment at t.Run
go/lib/hpkt/extension_test.go, line 34 at r1 (raw file):
ExpectedError bool } testCases := []*TestCase{
make this a map and use the description as key.
Because of go's non-deterministic map range, we can avoid having execution order dependencies in tests.
(This probably does not mattere here, but in other places where we test some stateful objects it is really useful)
tests := map[string]struct{
InputExtensions []common.Extension
ExpectedOutputHBH []common.Extension
ExpectedOutputE2E []common.Extension
ExpectedError bool
}{
...
}
go/lib/hpkt/extension_test.go, line 140 at r1 (raw file):
t.Run(tc.Description, func(t *testing.T) { hbh, e2e, err := ValidateExtensions(tc.InputExtensions) if tc.ExpectedError == true {
replace if/else with tc.Assertion(t, err)
go/lib/hpkt/hpkt_test.go, line 52 at r1 (raw file):
s := &spkt.ScnPkt{ DstIA: addr.IA{},
remove those two lines. They initialize the zero value?
go/lib/hpkt/hpkt_test.go, line 59 at r1 (raw file):
assert.Equal(t, s.DstIA.I, addr.ISD(2), "AddrHdr.DstIA.I") assert.Equal(t, s.DstIA.A, addr.AS(0xff0000000222), "AddrHdr.DstIA.A")
do xtest.MustParseAS(ff00:0:222)
go/lib/hpkt/hpkt_test.go, line 61 at r1 (raw file):
assert.Equal(t, s.DstIA.A, addr.AS(0xff0000000222), "AddrHdr.DstIA.A") assert.Equal(t, s.SrcIA.I, addr.ISD(1), "AddrHdr.SrcIA.I") assert.Equal(t, s.SrcIA.A, addr.AS(0xff0000000133), "AddrHdr.SrcIA.A")
ditto
go/lib/hpkt/hpkt_test.go, line 94 at r1 (raw file):
scmpHdr, ok := s.L4.(*scmp.Hdr) require.Equal(t, ok, true, "Bad L4Hdr, cannot continue")
require.True
go/lib/hpkt/hpkt_test.go, line 98 at r1 (raw file):
assert.Equal(t, scmpHdr.Class, scmp.C_Path, "SCMP.Class") assert.Equal(t, scmpHdr.Type, scmp.T_P_RevokedIF, "SCMP.Type") //// XXX(kormat): not maintainable:
remove the two added //
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: all files reviewed, 9 unresolved discussions (waiting on @karampok)
go/lib/hpkt/hpkt_test.go, line 39 at r1 (raw file):
) func mustLoad(path string) common.RawBytes {
you could use xtest.MustReadFromFile(t, path)
instead of mustLoad
. Note that xtest.MustReadFromFile
prepends the testdata
folder to the given path.
go/lib/hpkt/hpkt_test.go, line 98 at r1 (raw file): Previously, Oncilla wrote…
done |
df94d3a
to
8960334
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 1 of 3 files reviewed, 9 unresolved discussions (waiting on @lukedirtwalker and @oncilla)
go/lib/hpkt/extension_test.go, line 32 at r1 (raw file):
Previously, Oncilla wrote…
use
require.ErrorAssertionFunc
insteadi.e.
... ExpectedOutputE2E []common.Extension Assertion require.ErrorAssertionFunc }
and replace
ExpectedError: true
withrequire.Error
andExpectedError: false
withrequire.NoError
see how it is used in comment at
t.Run
Done.
go/lib/hpkt/extension_test.go, line 34 at r1 (raw file):
Previously, Oncilla wrote…
make this a map and use the description as key.
Because of go's non-deterministic map range, we can avoid having execution order dependencies in tests.
(This probably does not mattere here, but in other places where we test some stateful objects it is really useful)tests := map[string]struct{ InputExtensions []common.Extension ExpectedOutputHBH []common.Extension ExpectedOutputE2E []common.Extension ExpectedError bool }{ ... }
Done.
go/lib/hpkt/extension_test.go, line 140 at r1 (raw file):
Previously, Oncilla wrote…
replace if/else with
tc.Assertion(t, err)
Done.
go/lib/hpkt/hpkt_test.go, line 39 at r1 (raw file):
Previously, lukedirtwalker (Lukas Vogel) wrote…
you could use
xtest.MustReadFromFile(t, path)
instead ofmustLoad
. Note thatxtest.MustReadFromFile
prepends thetestdata
folder to the given path.
Done.
go/lib/hpkt/hpkt_test.go, line 52 at r1 (raw file):
Previously, Oncilla wrote…
remove those two lines. They initialize the zero value?
Done.
go/lib/hpkt/hpkt_test.go, line 59 at r1 (raw file):
Previously, Oncilla wrote…
do
xtest.MustParseAS(ff00:0:222)
Done.
go/lib/hpkt/hpkt_test.go, line 61 at r1 (raw file):
Previously, Oncilla wrote…
ditto
Done.
go/lib/hpkt/hpkt_test.go, line 94 at r1 (raw file):
Previously, Oncilla wrote…
require.True
Done.
8960334
to
cf06e92
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 3 of 3 files at r2.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @karampok and @lukedirtwalker)
go/lib/hpkt/extension_test.go, line 130 at r2 (raw file):
} for dscr, input := range tests {
we generally use name
and test
here.
go/lib/hpkt/hpkt_test.go, line 39 at r2 (raw file):
func TestParseScnPkt(t *testing.T) { //raw := common.RawBytes(xtest.MustReadFromFile(t, rawUDPPktFilename))
remove?
cf06e92
to
05e29fb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @lukedirtwalker and @oncilla)
go/lib/hpkt/extension_test.go, line 130 at r2 (raw file):
Previously, Oncilla wrote…
we generally use
name
andtest
here.
Done.
go/lib/hpkt/hpkt_test.go, line 39 at r2 (raw file):
Previously, Oncilla wrote…
remove?
yes sure
05e29fb
to
549e0fd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 2 of 2 files at r3.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @lukedirtwalker)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @lukedirtwalker)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: complete! all files reviewed, all discussions resolved
This change is