Skip to content

Commit

Permalink
chore: Flaky tests + linter upgrade
Browse files Browse the repository at this point in the history
Attempt to fix some flaky tests by adding more flushes.

Upgrade linter to v1.51.1 and fix reported issues.
  • Loading branch information
LBeernaertProton committed Mar 1, 2023
1 parent 3b1b90f commit be34573
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.50.0
version: v1.51.1
args: --timeout=500s
skip-cache: true

Expand Down
1 change: 1 addition & 0 deletions benchmarks/imaptest/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ func TestIMAPTest(t *testing.T) {
}
}

// nolint: musttag
type config struct {
Cases []caseConfig
Settings map[string]settingsConfig
Expand Down
4 changes: 2 additions & 2 deletions store/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ package store_test

import (
"bytes"
"github.com/ProtonMail/gluon/store/fallback_v0"
"math/rand"
"crypto/rand"
"os"
"path/filepath"
"runtime"
"testing"

"github.com/ProtonMail/gluon/imap"
"github.com/ProtonMail/gluon/store"
"github.com/ProtonMail/gluon/store/fallback_v0"
"github.com/stretchr/testify/require"
)

Expand Down
6 changes: 5 additions & 1 deletion tests/close_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func TestClose(t *testing.T) {
// This test is still useful as we have no way of checking the fetch responses after the store command.
// Additionally, we also need to ensure that there are no unilateral EXPUNGE messages returned from the server after close.
// There is currently no way to check for this with the go imap client.
runManyToOneTestWithAuth(t, defaultServerOptions(t), []int{1, 2}, func(c map[int]*testConnection, _ *testSession) {
runManyToOneTestWithAuth(t, defaultServerOptions(t), []int{1, 2}, func(c map[int]*testConnection, s *testSession) {
c[1].C("b001 CREATE saved-messages")
c[1].S("b001 OK CREATE")

Expand Down Expand Up @@ -52,6 +52,8 @@ func TestClose(t *testing.T) {
c[1].S(`* 3 FETCH (FLAGS (\Deleted \Recent \Seen))`)
c[1].Sx("A005 OK.*")

s.flush("user")

c[2].C("B003 NOOP")
c[2].S(
`* 1 FETCH (FLAGS (\Deleted \Seen))`,
Expand All @@ -67,6 +69,8 @@ func TestClose(t *testing.T) {
c[1].C(`A202 CLOSE`)
c[1].S("A202 OK CLOSE")

s.flush("user")

c[2].C("B003 NOOP")
c[2].S(
`* 1 EXPUNGE`,
Expand Down
6 changes: 5 additions & 1 deletion tests/multi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,15 @@ func TestExistsUpdatesInSeparateMailboxes(t *testing.T) {
}

func TestFetchUpdates(t *testing.T) {
runManyToOneTestWithAuth(t, defaultServerOptions(t), []int{1, 2}, func(c map[int]*testConnection, _ *testSession) {
runManyToOneTestWithAuth(t, defaultServerOptions(t), []int{1, 2}, func(c map[int]*testConnection, s *testSession) {
c[1].doAppend(`INBOX`, `To: [email protected]`, `\Seen`).expect("OK")

// First client selects in INBOX to receive FETCH update.
c[1].C("A006 select INBOX")
c[1].Se("A006 OK [READ-WRITE] SELECT")

s.flush("user")

// Second client selects in INBOX and then sets some flags to generate a FETCH update.
c[2].C("b006 select INBOX")
c[2].Se("b006 OK [READ-WRITE] SELECT")
Expand All @@ -65,6 +67,8 @@ func TestFetchUpdates(t *testing.T) {
c[2].S(`* 1 FETCH (FLAGS (\Deleted \Seen))`)
c[2].Sx("B007 OK .*")

s.flush("user")

// First client receives the FETCH update.
c[1].C("c001 noop")
c[1].S(`* 1 FETCH (FLAGS (\Deleted \Recent \Seen))`)
Expand Down

0 comments on commit be34573

Please sign in to comment.