Skip to content
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

Merged
merged 1 commit into from
Aug 27, 2019

Conversation

karampok
Copy link
Contributor

@karampok karampok commented Aug 23, 2019

This change is Reviewable

Copy link
Contributor

@oncilla oncilla left a 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 //

Copy link
Collaborator

@lukedirtwalker lukedirtwalker left a 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.

@karampok
Copy link
Contributor Author


go/lib/hpkt/hpkt_test.go, line 98 at r1 (raw file):

Previously, Oncilla wrote…

remove the two added //

done

Copy link
Contributor Author

@karampok karampok left a 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 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

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 of mustLoad. Note that xtest.MustReadFromFile prepends the testdata 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.

Copy link
Contributor

@oncilla oncilla left a 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?

Copy link
Contributor Author

@karampok karampok left a 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 and test here.

Done.


go/lib/hpkt/hpkt_test.go, line 39 at r2 (raw file):

Previously, Oncilla wrote…

remove?

yes sure

Copy link
Contributor

@oncilla oncilla left a 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)

Copy link
Contributor

@oncilla oncilla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @lukedirtwalker)

Copy link
Collaborator

@lukedirtwalker lukedirtwalker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

@karampok karampok merged commit 6e17dc3 into scionproto:master Aug 27, 2019
@karampok karampok deleted the remove-goconvey-from-hpkt branch August 27, 2019 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants