GODT-1815: Start with missing gluon files

This commit is contained in:
James Houlahan
2022-09-27 13:22:07 +02:00
parent 612fb7ad7b
commit 9670e29d9f
18 changed files with 241 additions and 101 deletions

View File

@ -86,6 +86,7 @@ func TestFeatures(testingT *testing.T) {
ctx.Step(`^the user changes the IMAP port to (\d+)$`, s.theUserChangesTheIMAPPortTo)
ctx.Step(`^the user changes the SMTP port to (\d+)$`, s.theUserChangesTheSMTPPortTo)
ctx.Step(`^the user changes the gluon path$`, s.theUserChangesTheGluonPath)
ctx.Step(`^the user deletes the gluon files$`, s.theUserDeletesTheGluonFiles)
ctx.Step(`^the user reports a bug$`, s.theUserReportsABug)
ctx.Step(`^bridge sends a connection up event$`, s.bridgeSendsAConnectionUpEvent)
ctx.Step(`^bridge sends a connection down event$`, s.bridgeSendsAConnectionDownEvent)
@ -127,6 +128,7 @@ func TestFeatures(testingT *testing.T) {
ctx.Step(`^IMAP client "([^"]*)" deletes "([^"]*)"$`, s.imapClientDeletesMailbox)
ctx.Step(`^IMAP client "([^"]*)" renames "([^"]*)" to "([^"]*)"$`, s.imapClientRenamesMailboxTo)
ctx.Step(`^IMAP client "([^"]*)" sees the following mailbox info:$`, s.imapClientSeesTheFollowingMailboxInfo)
ctx.Step(`^IMAP client "([^"]*)" eventually sees the following mailbox info:$`, s.imapClientEventuallySeesTheFollowingMailboxInfo)
ctx.Step(`^IMAP client "([^"]*)" sees the following mailbox info for "([^"]*)":$`, s.imapClientSeesTheFollowingMailboxInfoForMailbox)
ctx.Step(`^IMAP client "([^"]*)" sees the following mailboxes:$`, s.imapClientSeesTheFollowingMailboxes)
ctx.Step(`^IMAP client "([^"]*)" sees "([^"]*)"$`, s.imapClientSeesMailbox)

View File

@ -55,6 +55,15 @@ func (s *scenario) theUserChangesTheGluonPath() error {
return s.t.bridge.SetGluonDir(context.Background(), gluonDir)
}
func (s *scenario) theUserDeletesTheGluonFiles() error {
path, err := s.t.locator.ProvideGluonPath()
if err != nil {
return err
}
return os.RemoveAll(path)
}
func (s *scenario) theUserHasDisabledAutomaticUpdates() error {
var started bool

View File

@ -70,13 +70,15 @@ type smtpClient struct {
}
func newTestCtx(tb testing.TB) *testCtx {
dir := tb.TempDir()
dialer := bridge.NewTestDialer()
ctx := &testCtx{
dir: tb.TempDir(),
dir: dir,
api: newFakeAPI(),
dialer: dialer,
locator: locations.New(bridge.NewTestLocationsProvider(tb), "config-name"),
locator: locations.New(bridge.NewTestLocationsProvider(dir), "config-name"),
storeKey: []byte("super-secret-store-key"),
mocks: bridge.NewMocks(tb, dialer, defaultVersion, defaultVersion),
version: defaultVersion,

View File

@ -22,6 +22,29 @@ Feature: Bridge can fully sync an account
When bridge restarts
And user "user@pm.me" connects and authenticates IMAP client "1"
Then IMAP client "1" sees the following mailbox info:
| name | total | unread |
| INBOX | 0 | 0 |
| Drafts | 0 | 0 |
| Sent | 0 | 0 |
| Starred | 0 | 0 |
| Archive | 0 | 0 |
| Spam | 0 | 0 |
| Trash | 0 | 0 |
| All Mail | 4 | 2 |
| Folders | 0 | 0 |
| Folders/one | 2 | 1 |
| Folders/two | 2 | 1 |
| Labels | 0 | 0 |
| Labels/three | 0 | 0 |
Scenario: If the gluon files are deleted, the account is synced again
Given the user logs in with username "user@pm.me" and password "password"
And user "user@pm.me" finishes syncing
And bridge stops
And the user deletes the gluon files
And bridge starts
When user "user@pm.me" connects and authenticates IMAP client "1"
Then IMAP client "1" eventually sees the following mailbox info:
| name | total | unread |
| INBOX | 0 | 0 |
| Drafts | 0 | 0 |

View File

@ -124,6 +124,14 @@ func (s *scenario) imapClientSeesTheFollowingMailboxInfo(clientID string, table
return matchMailboxes(haveMailboxes, table)
}
func (s *scenario) imapClientEventuallySeesTheFollowingMailboxInfo(clientID string, table *godog.Table) error {
return eventually(
func() error { return s.imapClientSeesTheFollowingMailboxInfo(clientID, table) },
5*time.Second,
100*time.Millisecond,
)
}
func (s *scenario) imapClientSeesTheFollowingMailboxInfoForMailbox(clientID, mailbox string, table *godog.Table) error {
_, client := s.t.getIMAPClient(clientID)