Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a4e038f

Browse files
committed
Remove underscore from test names
unexport fields from zobject
1 parent e482d2c commit a4e038f

9 files changed

+19
-19
lines changed

coderd/authz/authz_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111

1212
var nilSet = authztest.Set{nil}
1313

14-
func Test_ExhaustiveAuthorize(t *testing.T) {
14+
func TestExhaustiveAuthorize(t *testing.T) {
1515
t.Parallel()
1616

1717
all := authztest.GroupedPermissions(authztest.AllPermissions())

coderd/authz/authztest/level_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"github.com/coder/coder/coderd/authz/authztest"
1010
)
1111

12-
func Test_GroupedPermissions(t *testing.T) {
12+
func TestGroupedPermissions(t *testing.T) {
1313
t.Parallel()
1414

1515
set := make(authztest.Set, 0)

coderd/authz/authztest/permissions_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"github.com/coder/coder/coderd/authz/authztest"
99
)
1010

11-
func Test_AllPermissions(t *testing.T) {
11+
func TestAllPermissions(t *testing.T) {
1212
t.Parallel()
1313

1414
// If this changes, then we might have to fix some other tests. This constant

coderd/authz/authztest/role_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
crand "github.com/coder/coder/cryptorand"
1010
)
1111

12-
func Test_NewRole(t *testing.T) {
12+
func TestNewRole(t *testing.T) {
1313
t.Parallel()
1414

1515
for i := 0; i < 50; i++ {

coderd/authz/authztest/set_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
crand "github.com/coder/coder/cryptorand"
1111
)
1212

13-
func Test_Set(t *testing.T) {
13+
func TestSet(t *testing.T) {
1414
t.Parallel()
1515

1616
t.Run("Simple", func(t *testing.T) {

coderd/authz/example_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import (
88
"github.com/coder/coder/coderd/authz"
99
)
1010

11-
// Test_Example gives some examples on how to use the authz library.
11+
// TestExample gives some examples on how to use the authz library.
1212
// This serves to test syntax more than functionality.
13-
func Test_Example(t *testing.T) {
13+
func TestExample(t *testing.T) {
1414
t.Parallel()
1515

1616
// user will become an authn object, and can even be a database.User if it

coderd/authz/object.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,25 @@ var _ OrgResource = (*zObject)(nil)
2525
// that represents the set of workspaces you are trying to get access too.
2626
// Do not export this type, as it can be created from a resource type constant.
2727
type zObject struct {
28-
ObjectID string `json:"object_id"`
29-
OwnedBy string `json:"owner_id"`
30-
OwnedByOrg string `json:"org_owner_id"`
28+
id string
29+
owner string
30+
OwnedByOrg string
3131

3232
// ObjectType is "workspace", "project", "devurl", etc
33-
ObjectType ResourceType `json:"object_type"`
33+
ObjectType ResourceType
3434
// TODO: SharedUsers?
3535
}
3636

3737
func (z zObject) ID() string {
38-
return z.ObjectID
38+
return z.id
3939
}
4040

4141
func (z zObject) ResourceType() ResourceType {
4242
return z.ObjectType
4343
}
4444

4545
func (z zObject) OwnerID() string {
46-
return z.OwnedBy
46+
return z.owner
4747
}
4848

4949
func (z zObject) OrgOwnerID() string {
@@ -60,12 +60,12 @@ func (z zObject) Org(orgID string) zObject {
6060
// Owner adds an OwnerID to the resource
6161
//nolint:revive
6262
func (z zObject) Owner(id string) zObject {
63-
z.OwnedBy = id
63+
z.owner = id
6464
return z
6565
}
6666

6767
//nolint:revive
6868
func (z zObject) AsID(id string) zObject {
69-
z.ObjectID = id
69+
z.id = id
7070
return z
7171
}

coderd/authz/permission_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"github.com/coder/coder/coderd/authz"
99
)
1010

11-
func Test_PermissionString(t *testing.T) {
11+
func TestPermissionString(t *testing.T) {
1212
t.Parallel()
1313

1414
testCases := []struct {
@@ -72,7 +72,7 @@ func Test_PermissionString(t *testing.T) {
7272
}
7373
}
7474

75-
func Test_ParsePermissions(t *testing.T) {
75+
func TestParsePermissions(t *testing.T) {
7676
t.Parallel()
7777

7878
testCases := []struct {

coderd/authz/resources.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ func (r ResourceType) Org(orgID string) zObject {
3131
//nolint:revive
3232
func (r ResourceType) Owner(id string) zObject {
3333
return zObject{
34-
OwnedBy: id,
34+
owner: id,
3535
ObjectType: r,
3636
}
3737
}
3838

3939
//nolint:revive
4040
func (r ResourceType) AsID(id string) zObject {
4141
return zObject{
42-
ObjectID: id,
42+
id: id,
4343
ObjectType: r,
4444
}
4545
}

0 commit comments

Comments
 (0)