Skip to content

Commit 5d34d05

Browse files
chore: Lint fixes part 7 (#2637)
Co-authored-by: James Thomas <[email protected]>
1 parent f702cb9 commit 5d34d05

File tree

11 files changed

+67
-62
lines changed

11 files changed

+67
-62
lines changed

internal/caveats/builder_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ func TestMustCaveatExprForTestingWithContext(t *testing.T) {
228228

229229
contextMap := result.GetCaveat().Context.AsMap()
230230
require.Equal(t, "value1", contextMap["key1"])
231-
require.Equal(t, float64(42), contextMap["key2"])
231+
require.Equal(t, float64(42), contextMap["key2"]) //nolint:testifyrequire these are known/static values
232232
}
233233

234234
func TestMustCaveatExprForTestingWithContextPanic(t *testing.T) {

internal/datastore/revisions/hlcrevision_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ func TestInexactFloat64(t *testing.T) {
108108
rev, err := HLCRevisionFromString(tc)
109109
require.NoError(t, err)
110110

111-
require.Equal(t, floatValue, rev.InexactFloat64())
111+
require.Equal(t, floatValue, rev.InexactFloat64()) //nolint:testifyrequire this is based on a parsed value, so we expect it to be exactly equal.
112112
})
113113
}
114114
}

internal/developmentmembership/foundsubject.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,12 @@ func (fs FoundSubject) ToValidationString() string {
8989
onrString := tuple.StringONR(fs.Subject())
9090
validationString := onrString
9191
if fs.caveatExpression != nil {
92-
validationString = validationString + "[...]"
92+
validationString += "[...]"
9393
}
9494

9595
excluded, isWildcard := fs.ExcludedSubjectsFromWildcard()
9696
if isWildcard && len(excluded) > 0 {
97-
validationString = validationString + " - {" + strings.Join(fs.excludedSubjectStrings(), ", ") + "}"
97+
validationString += " - {" + strings.Join(fs.excludedSubjectStrings(), ", ") + "}"
9898
}
9999

100100
return validationString

internal/dispatch/graph/check_test.go

Lines changed: 38 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ func TestCheckPermissionOverSchema(t *testing.T) {
310310
{
311311
"basic union",
312312
`definition user {}
313-
313+
314314
definition document {
315315
relation editor: user
316316
relation viewer: user
@@ -328,7 +328,7 @@ func TestCheckPermissionOverSchema(t *testing.T) {
328328
{
329329
"basic intersection",
330330
`definition user {}
331-
331+
332332
definition document {
333333
relation editor: user
334334
relation viewer: user
@@ -347,7 +347,7 @@ func TestCheckPermissionOverSchema(t *testing.T) {
347347
{
348348
"basic exclusion",
349349
`definition user {}
350-
350+
351351
definition document {
352352
relation editor: user
353353
relation viewer: user
@@ -365,7 +365,7 @@ func TestCheckPermissionOverSchema(t *testing.T) {
365365
{
366366
"basic union, multiple branches",
367367
`definition user {}
368-
368+
369369
definition document {
370370
relation editor: user
371371
relation viewer: user
@@ -384,7 +384,7 @@ func TestCheckPermissionOverSchema(t *testing.T) {
384384
{
385385
"basic union no permission",
386386
`definition user {}
387-
387+
388388
definition document {
389389
relation editor: user
390390
relation viewer: user
@@ -400,7 +400,7 @@ func TestCheckPermissionOverSchema(t *testing.T) {
400400
{
401401
"basic intersection no permission",
402402
`definition user {}
403-
403+
404404
definition document {
405405
relation editor: user
406406
relation viewer: user
@@ -418,7 +418,7 @@ func TestCheckPermissionOverSchema(t *testing.T) {
418418
{
419419
"basic exclusion no permission",
420420
`definition user {}
421-
421+
422422
definition document {
423423
relation banned: user
424424
relation viewer: user
@@ -437,7 +437,7 @@ func TestCheckPermissionOverSchema(t *testing.T) {
437437
{
438438
"exclusion with multiple branches",
439439
`definition user {}
440-
440+
441441
definition group {
442442
relation member: user
443443
relation banned: user
@@ -464,7 +464,7 @@ func TestCheckPermissionOverSchema(t *testing.T) {
464464
{
465465
"intersection with multiple branches",
466466
`definition user {}
467-
467+
468468
definition group {
469469
relation member: user
470470
relation other: user
@@ -491,7 +491,7 @@ func TestCheckPermissionOverSchema(t *testing.T) {
491491
{
492492
"exclusion with multiple branches no permission",
493493
`definition user {}
494-
494+
495495
definition group {
496496
relation member: user
497497
relation banned: user
@@ -519,7 +519,7 @@ func TestCheckPermissionOverSchema(t *testing.T) {
519519
{
520520
"intersection with multiple branches no permission",
521521
`definition user {}
522-
522+
523523
definition group {
524524
relation member: user
525525
relation other: user
@@ -549,7 +549,7 @@ func TestCheckPermissionOverSchema(t *testing.T) {
549549
definition organization {
550550
relation member: user
551551
}
552-
552+
553553
definition document {
554554
relation orgs: organization
555555
permission view = orgs->member
@@ -572,7 +572,7 @@ func TestCheckPermissionOverSchema(t *testing.T) {
572572
definition organization {
573573
relation member: user
574574
}
575-
575+
576576
definition document {
577577
relation orgs: organization
578578
permission view = orgs.any(member)
@@ -595,7 +595,7 @@ func TestCheckPermissionOverSchema(t *testing.T) {
595595
definition organization {
596596
relation member: user
597597
}
598-
598+
599599
definition document {
600600
relation orgs: organization
601601
permission view = orgs.all(member)
@@ -618,7 +618,7 @@ func TestCheckPermissionOverSchema(t *testing.T) {
618618
definition organization {
619619
relation member: user
620620
}
621-
621+
622622
definition document {
623623
relation orgs: organization
624624
permission view = orgs.all(member)
@@ -646,7 +646,7 @@ func TestCheckPermissionOverSchema(t *testing.T) {
646646
definition someotherresource {
647647
relation member: user
648648
}
649-
649+
650650
definition document {
651651
relation orgs: organization | someotherresource
652652
permission view = orgs.all(member)
@@ -674,7 +674,7 @@ func TestCheckPermissionOverSchema(t *testing.T) {
674674
definition someotherresource {
675675
relation member: user
676676
}
677-
677+
678678
definition document {
679679
relation orgs: organization | someotherresource
680680
permission view = orgs.all(member)
@@ -703,7 +703,7 @@ func TestCheckPermissionOverSchema(t *testing.T) {
703703
definition someotherresource {
704704
relation member: user
705705
}
706-
706+
707707
definition document {
708708
relation orgs: organization | someotherresource
709709
permission view = orgs.all(member)
@@ -729,7 +729,7 @@ func TestCheckPermissionOverSchema(t *testing.T) {
729729
definition organization {
730730
relation member: user
731731
}
732-
732+
733733
definition document {
734734
relation orgs: organization
735735
permission view = orgs.all(member)
@@ -751,7 +751,7 @@ func TestCheckPermissionOverSchema(t *testing.T) {
751751
definition organization {
752752
relation member: user
753753
}
754-
754+
755755
definition document {
756756
relation orgs: organization
757757
permission view = orgs.all(member)
@@ -1292,7 +1292,7 @@ func TestCheckPermissionOverSchema(t *testing.T) {
12921292
}
12931293
12941294
definition user {}
1295-
1295+
12961296
definition role {
12971297
relation member: user with somecaveat
12981298
}
@@ -1324,23 +1324,23 @@ func TestCheckPermissionOverSchema(t *testing.T) {
13241324
name: "caveated_with_arrows",
13251325
schema: `
13261326
definition user {}
1327-
1327+
13281328
definition office {
13291329
relation parent: office
13301330
relation manager: user
13311331
permission read = manager + parent->read
13321332
}
1333-
1333+
13341334
definition group {
13351335
relation parent: office
13361336
permission read = parent->read
13371337
}
1338-
1338+
13391339
definition document {
13401340
relation owner: group with equals
13411341
permission read = owner->read
13421342
}
1343-
1343+
13441344
caveat equals(actual string, required string) {
13451345
actual == required
13461346
}
@@ -1369,23 +1369,23 @@ func TestCheckPermissionOverSchema(t *testing.T) {
13691369
name: "caveated_nested_with_intersection_arrows",
13701370
schema: `
13711371
definition user {}
1372-
1372+
13731373
definition office {
13741374
relation parent: office
13751375
relation manager: user
13761376
permission read = manager + parent.all(read)
13771377
}
1378-
1378+
13791379
definition group {
13801380
relation parent: office
13811381
permission read = parent.all(read)
13821382
}
1383-
1383+
13841384
definition document {
13851385
relation owner: group with equals
13861386
permission read = owner.all(read)
13871387
}
1388-
1388+
13891389
caveat equals(actual string, required string) {
13901390
actual == required
13911391
}
@@ -1601,7 +1601,7 @@ func TestCheckWithHints(t *testing.T) {
16011601
{
16021602
"no relationships",
16031603
`definition user {}
1604-
1604+
16051605
definition document {
16061606
relation editor: user
16071607
relation viewer: user
@@ -1616,7 +1616,7 @@ func TestCheckWithHints(t *testing.T) {
16161616
{
16171617
"no relationships with matching check hint",
16181618
`definition user {}
1619-
1619+
16201620
definition document {
16211621
relation editor: user
16221622
relation viewer: user
@@ -1633,7 +1633,7 @@ func TestCheckWithHints(t *testing.T) {
16331633
{
16341634
"no relationships with unrelated check hint",
16351635
`definition user {}
1636-
1636+
16371637
definition document {
16381638
relation editor: user
16391639
relation viewer: user
@@ -1650,7 +1650,7 @@ func TestCheckWithHints(t *testing.T) {
16501650
{
16511651
"no relationships with unrelated check hint due to subject",
16521652
`definition user {}
1653-
1653+
16541654
definition document {
16551655
relation editor: user
16561656
relation viewer: user
@@ -1667,7 +1667,7 @@ func TestCheckWithHints(t *testing.T) {
16671667
{
16681668
"no relationships with matching arrow check hint",
16691669
`definition user {}
1670-
1670+
16711671
definition organization {
16721672
relation member: user
16731673
}
@@ -1687,7 +1687,7 @@ func TestCheckWithHints(t *testing.T) {
16871687
{
16881688
"no relationships with non matching tupleset arrow check hint",
16891689
`definition user {}
1690-
1690+
16911691
definition organization {
16921692
relation member: user
16931693
}
@@ -1707,7 +1707,7 @@ func TestCheckWithHints(t *testing.T) {
17071707
{
17081708
"no relationships with non matching computed userset arrow check hint",
17091709
`definition user {}
1710-
1710+
17111711
definition organization {
17121712
relation member: user
17131713
}
@@ -1953,10 +1953,8 @@ func TestCheckWithHints(t *testing.T) {
19531953
if tc.expectedPermissionship {
19541954
require.True(ok)
19551955
require.Equal(v1.ResourceCheckResult_MEMBER, resp.ResultsByResourceId[tc.resource.ObjectID].Membership)
1956-
} else {
1957-
if ok {
1958-
require.Equal(v1.ResourceCheckResult_NOT_MEMBER, resp.ResultsByResourceId[tc.resource.ObjectID].Membership)
1959-
}
1956+
} else if ok {
1957+
require.Equal(v1.ResourceCheckResult_NOT_MEMBER, resp.ResultsByResourceId[tc.resource.ObjectID].Membership)
19601958
}
19611959
})
19621960
}

internal/dispatch/singleflight/singleflight_test.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,29 +187,35 @@ func TestSingleFlightDispatcherCancelation(t *testing.T) {
187187
disp := New(mockDispatcher{f: f}, &keys.DirectKeyHandler{})
188188
wg := sync.WaitGroup{}
189189
wg.Add(3)
190+
errs := make(chan error, 3)
191+
190192
go func() {
191193
ctx, cancel := context.WithTimeout(t.Context(), time.Millisecond*50)
192194
defer cancel()
193195
_, err := disp.DispatchCheck(ctx, req.CloneVT())
196+
errs <- err
194197
wg.Done()
195-
require.ErrorIs(t, err, context.DeadlineExceeded)
196198
}()
197199
go func() {
198200
ctx, cancel := context.WithTimeout(t.Context(), time.Millisecond*50)
199201
defer cancel()
200202
_, err := disp.DispatchCheck(ctx, req.CloneVT())
203+
errs <- err
201204
wg.Done()
202-
require.ErrorIs(t, err, context.DeadlineExceeded)
203205
}()
204206
go func() {
205207
ctx, cancel := context.WithTimeout(t.Context(), time.Millisecond*50)
206208
defer cancel()
207209
_, err := disp.DispatchCheck(ctx, req.CloneVT())
210+
errs <- err
208211
wg.Done()
209-
require.ErrorIs(t, err, context.DeadlineExceeded)
210212
}()
211213

212214
wg.Wait()
215+
close(errs)
216+
for err := range errs {
217+
require.ErrorIs(t, err, context.DeadlineExceeded)
218+
}
213219
<-run
214220
require.Equal(t, uint64(1), called.Load())
215221
}

0 commit comments

Comments
 (0)