summaryrefslogtreecommitdiff
path: root/internal/db/bundb/application_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/db/bundb/application_test.go')
-rw-r--r--internal/db/bundb/application_test.go32
1 files changed, 31 insertions, 1 deletions
diff --git a/internal/db/bundb/application_test.go b/internal/db/bundb/application_test.go
index b6b19319c..540c632b5 100644
--- a/internal/db/bundb/application_test.go
+++ b/internal/db/bundb/application_test.go
@@ -92,7 +92,7 @@ func (suite *ApplicationTestSuite) TestDeleteApplicationBy() {
for _, app := range suite.testApplications {
for lookup, dbfunc := range map[string]func() error{
"client_id": func() error {
- return suite.db.DeleteApplicationByClientID(ctx, app.ClientID)
+ return suite.db.DeleteApplicationByID(ctx, app.ID)
},
} {
// Clear database caches.
@@ -124,6 +124,36 @@ func (suite *ApplicationTestSuite) TestGetAllTokens() {
suite.NotEmpty(tokens)
}
+func (suite *ApplicationTestSuite) TestDeleteTokensByClientID() {
+ ctx := context.Background()
+
+ // Delete tokens by each app.
+ for _, app := range suite.testApplications {
+ if err := suite.state.DB.DeleteTokensByClientID(ctx, app.ClientID); err != nil {
+ suite.FailNow(err.Error())
+ }
+ }
+
+ // Ensure all tokens deleted.
+ for _, token := range suite.testTokens {
+ _, err := suite.db.GetTokenByID(ctx, token.ID)
+ if !errors.Is(err, db.ErrNoEntries) {
+ suite.FailNow("", "token %s not deleted", token.ID)
+ }
+ }
+}
+
+func (suite *ApplicationTestSuite) TestDeleteTokensByUnknownClientID() {
+ // Should not return ErrNoRows even though
+ // the client with given ID doesn't exist.
+ if err := suite.state.DB.DeleteTokensByClientID(
+ context.Background(),
+ "01JPJ4NCGH6GHY7ZVYBHNP55XS",
+ ); err != nil {
+ suite.FailNow(err.Error())
+ }
+}
+
func TestApplicationTestSuite(t *testing.T) {
suite.Run(t, new(ApplicationTestSuite))
}