Skip to content

Commit

Permalink
Prevent async errors
Browse files Browse the repository at this point in the history
  • Loading branch information
blaubaer committed Oct 11, 2024
1 parent 539bb63 commit d887d5f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pkg/user/etc-colon-repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ bar:XbarX:20453:10:100:::20818:`,
groupFile := dir.file("group").setContent(c.group)
shadowFile := dir.file("shadow").setContent(c.shadow)

var asyncError error
instance := EtcColonRepository{
PasswdFilename: passwdFile.name(),
GroupFilename: groupFile.name(),
Expand All @@ -426,6 +427,11 @@ bar:XbarX:20453:10:100:::20818:`,
AllowBadLine: &c.allowBadLine,
OnUnhandledAsyncError: c.onUnhandledAsyncError,
}
if instance.OnUnhandledAsyncError == nil {
instance.OnUnhandledAsyncError = func(_ log.Logger, err error, _ string) {
asyncError = err
}
}

actualErr := instance.Init(context.Background())
if expectedErr := c.expectedError; expectedErr != "" {
Expand All @@ -440,6 +446,8 @@ bar:XbarX:20453:10:100:::20818:`,

actualErr = instance.Close()
require.NoError(t, actualErr)

require.NoError(t, asyncError)
})
}
}
Expand Down Expand Up @@ -1454,6 +1462,7 @@ expired-ts:$y$j9T$as2ASyXW241FbtyMlNNQU1$sy6H9k6uXgaY1DeIKI5zPVsczWLD82k5UeQVuIM
require.NoError(t, actualErr)

assert.NoError(t, syncError)
time.Sleep(150 * time.Millisecond)
})
}
}
Expand Down

0 comments on commit d887d5f

Please sign in to comment.