forked from Silverfish/proton-bridge
Other: Add missing t.bridge = nil line
This commit is contained in:
@ -23,28 +23,11 @@ import (
|
|||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/ProtonMail/proton-bridge/v2/internal/certs"
|
|
||||||
"github.com/ProtonMail/proton-bridge/v2/internal/user"
|
|
||||||
"github.com/cucumber/godog"
|
"github.com/cucumber/godog"
|
||||||
"gitlab.protontech.ch/go/liteapi/server/backend"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
|
||||||
// Use the fast key generation for tests.
|
|
||||||
backend.GenerateKey = FastGenerateKey
|
|
||||||
|
|
||||||
// Use the fast cert generation for tests.
|
|
||||||
certs.GenerateCert = FastGenerateCert
|
|
||||||
|
|
||||||
// Set the event period to 100 milliseconds for more responsive tests.
|
|
||||||
user.EventPeriod = 100 * time.Millisecond
|
|
||||||
|
|
||||||
// Don't use jitter during tests.
|
|
||||||
user.EventJitter = 0
|
|
||||||
}
|
|
||||||
|
|
||||||
type scenario struct {
|
type scenario struct {
|
||||||
t *testCtx
|
t *testCtx
|
||||||
}
|
}
|
||||||
@ -78,8 +61,19 @@ func TestFeatures(testingT *testing.T) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
ctx.StepContext().Before(func(ctx context.Context, st *godog.Step) (context.Context, error) {
|
ctx.StepContext().Before(func(ctx context.Context, st *godog.Step) (context.Context, error) {
|
||||||
s.t.beforeStep()
|
// Replace [GOOS] with the current OS.
|
||||||
|
// Note: should add a generic replacement function on the test context to handle more cases!
|
||||||
st.Text = strings.ReplaceAll(st.Text, "[GOOS]", runtime.GOOS)
|
st.Text = strings.ReplaceAll(st.Text, "[GOOS]", runtime.GOOS)
|
||||||
|
|
||||||
|
logrus.Debugf("Running step: %s", st.Text)
|
||||||
|
|
||||||
|
s.t.beforeStep()
|
||||||
|
|
||||||
|
return ctx, nil
|
||||||
|
})
|
||||||
|
|
||||||
|
ctx.StepContext().After(func(ctx context.Context, st *godog.Step, status godog.StepResultStatus, err error) (context.Context, error) {
|
||||||
|
logrus.Debugf("Finished step (%v): %s", status, st.Text)
|
||||||
return ctx, nil
|
return ctx, nil
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@ -181,6 +181,8 @@ func (t *testCtx) closeBridge(ctx context.Context) error {
|
|||||||
|
|
||||||
t.bridge.Close(ctx)
|
t.bridge.Close(ctx)
|
||||||
|
|
||||||
|
t.bridge = nil
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
40
tests/init_test.go
Normal file
40
tests/init_test.go
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
// Copyright (c) 2022 Proton AG
|
||||||
|
//
|
||||||
|
// This file is part of Proton Mail Bridge.Bridge.
|
||||||
|
//
|
||||||
|
// Proton Mail Bridge is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// Proton Mail Bridge is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with Proton Mail Bridge. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
package tests
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/ProtonMail/proton-bridge/v2/internal/certs"
|
||||||
|
"github.com/ProtonMail/proton-bridge/v2/internal/user"
|
||||||
|
"gitlab.protontech.ch/go/liteapi/server/backend"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
// Use the fast key generation for tests.
|
||||||
|
backend.GenerateKey = FastGenerateKey
|
||||||
|
|
||||||
|
// Use the fast cert generation for tests.
|
||||||
|
certs.GenerateCert = FastGenerateCert
|
||||||
|
|
||||||
|
// Set the event period to 100 milliseconds for more responsive tests.
|
||||||
|
user.EventPeriod = 100 * time.Millisecond
|
||||||
|
|
||||||
|
// Don't use jitter during tests.
|
||||||
|
user.EventJitter = 0
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user