Skip to content

Commit

Permalink
chore: test coverage for append variants
Browse files Browse the repository at this point in the history
  • Loading branch information
johnabass committed Aug 19, 2024
1 parent 92c2529 commit 135a281
Showing 1 changed file with 54 additions and 23 deletions.
77 changes: 54 additions & 23 deletions approver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,32 +53,63 @@ func (suite *ApproversTestSuite) TestAuthorize() {
},
}

for _, testCase := range testCases {
suite.Run(testCase.name, func() {
var (
testCtx = suite.testContext()
testToken = suite.testToken()
as Approvers[string]
)
suite.Run("Append", func() {
for _, testCase := range testCases {
suite.Run(testCase.name, func() {
var (
testCtx = suite.testContext()
testToken = suite.testToken()
as Approvers[string]
)

for _, err := range testCase.results {
err := err
as = as.Append(
ApproverFunc[string](func(ctx context.Context, resource string, token Token) error {
suite.Same(testCtx, ctx)
suite.Equal(testToken, token)
suite.Equal(placeholderResource, resource)
return err
}),
for _, err := range testCase.results {
err := err
as = as.Append(
ApproverFunc[string](func(ctx context.Context, resource string, token Token) error {
suite.Same(testCtx, ctx)
suite.Equal(testToken, token)
suite.Equal(placeholderResource, resource)
return err
}),
)
}

suite.Equal(
testCase.expectedErr,
as.Approve(testCtx, placeholderResource, testToken),
)
})
}
})

suite.Run("AppendFunc", func() {
for _, testCase := range testCases {
suite.Run(testCase.name, func() {
var (
testCtx = suite.testContext()
testToken = suite.testToken()
as Approvers[string]
)
}

suite.Equal(
testCase.expectedErr,
as.Approve(testCtx, placeholderResource, testToken),
)
})
}
for _, err := range testCase.results {
err := err
as = as.AppendFunc(
func(ctx context.Context, resource string, token Token) error {
suite.Same(testCtx, ctx)
suite.Equal(testToken, token)
suite.Equal(placeholderResource, resource)
return err
},
)
}

suite.Equal(
testCase.expectedErr,
as.Approve(testCtx, placeholderResource, testToken),
)
})
}
})
}

func (suite *ApproversTestSuite) TestAny() {
Expand Down

0 comments on commit 135a281

Please sign in to comment.