-
Notifications
You must be signed in to change notification settings - Fork 671
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
refactor: introduce *test
packages in lieu of //go:build test
#3238
Changes from 23 commits
efa5a74
b843a56
1012187
7d552b8
34fd483
ef718a1
bda8137
9a301dd
bd9fea9
0e96fa4
e38117f
82991fd
3a095e1
28f2de9
049948b
403501d
891e7fe
7e2f1d7
37b9e20
9b9a5da
3c505f9
52bf535
9430f4c
1377cb4
d44ea82
968e3ef
17c63ff
2a031b2
3203eac
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,14 @@ | ||
// Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. | ||
// See the file LICENSE for licensing terms. | ||
|
||
//go:build test | ||
|
||
package cache | ||
package cachetest | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think there are a number of fields that stutter based on this rename - do we want to rename things like If we want to move that into a followup because the change right now is "methodical" whereas this would be a bit more of a "case-by-case" basis... I think that's fine... But I think it should be a fast-follow... Not an amorphous TODO (I'd personally be in-favor of just cleaning them up in this PR) I think this applies to most (if not all) of the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. They were deliberately ignored to be allow this PR to have the smallest possible footprint required to remove test tags. I'll do them as an immediate PR (might even be ready before you re-review this one). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I take this back. There are sooooo many of them. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/ava-labs/avalanchego/cache" | ||
"github.com/ava-labs/avalanchego/ids" | ||
) | ||
|
||
|
@@ -22,13 +21,13 @@ func TestIntSizeFunc(ids.ID, int64) int { | |
// CacherTests is a list of all Cacher tests | ||
var CacherTests = []struct { | ||
Size int | ||
Func func(t *testing.T, c Cacher[ids.ID, int64]) | ||
Func func(t *testing.T, c cache.Cacher[ids.ID, int64]) | ||
}{ | ||
{Size: 1, Func: TestBasic}, | ||
{Size: 2, Func: TestEviction}, | ||
} | ||
|
||
func TestBasic(t *testing.T, cache Cacher[ids.ID, int64]) { | ||
func TestBasic(t *testing.T, cache cache.Cacher[ids.ID, int64]) { | ||
require := require.New(t) | ||
|
||
id1 := ids.ID{1} | ||
|
@@ -63,7 +62,7 @@ func TestBasic(t *testing.T, cache Cacher[ids.ID, int64]) { | |
require.Equal(expectedValue2, value) | ||
} | ||
|
||
func TestEviction(t *testing.T, cache Cacher[ids.ID, int64]) { | ||
func TestEviction(t *testing.T, cache cache.Cacher[ids.ID, int64]) { | ||
require := require.New(t) | ||
|
||
id1 := ids.ID{1} | ||
|
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.
ni: seems can be put back
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.
I think having the dot import be the bottom makes sense
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.
This was a deliberate change to make the dot imports more obvious (I think it should be done for "blank" underscore imports too, but that's beyond this PR).
Both dot and underscore imports fundamentally change the way the rest of the code works, but in a way that's easily missed. Having them called out through placement is one way to mitigate this.