Remove Golang 1.24 compatibility for synctest.Test.

This commit is contained in:
Joachim Bauch 2026-02-12 08:59:34 +01:00
commit bd8c758847
No known key found for this signature in database
GPG key ID: 77C1D22D53E15F02
10 changed files with 18 additions and 136 deletions

View file

@ -29,13 +29,11 @@ import (
"time"
"github.com/stretchr/testify/assert"
"github.com/strukturag/nextcloud-spreed-signaling/test"
)
func Test_TransientData(t *testing.T) {
t.Parallel()
test.SynctestTest(t, func(t *testing.T) {
synctest.Test(t, func(t *testing.T) {
assert := assert.New(t)
data := NewTransientData()
assert.False(data.Set("foo", nil))
@ -190,7 +188,7 @@ func Test_TransientDataNotifyInitial(t *testing.T) {
func Test_TransientDataSetInitial(t *testing.T) {
t.Parallel()
test.SynctestTest(t, func(t *testing.T) {
synctest.Test(t, func(t *testing.T) {
assert := assert.New(t)
now := time.Now()

View file

@ -24,17 +24,16 @@ package async
import (
"context"
"testing"
"testing/synctest"
"time"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/strukturag/nextcloud-spreed-signaling/test"
)
func TestBackoff_Exponential(t *testing.T) {
t.Parallel()
test.SynctestTest(t, func(t *testing.T) {
synctest.Test(t, func(t *testing.T) {
assert := assert.New(t)
minWait := 100 * time.Millisecond
backoff, err := NewExponentialBackoff(minWait, 500*time.Millisecond)

View file

@ -23,12 +23,12 @@ package async
import (
"testing"
"testing/synctest"
"time"
"github.com/stretchr/testify/assert"
logtest "github.com/strukturag/nextcloud-spreed-signaling/log/test"
"github.com/strukturag/nextcloud-spreed-signaling/test"
)
func TestDeferredExecutor_MultiClose(t *testing.T) {
@ -43,7 +43,7 @@ func TestDeferredExecutor_MultiClose(t *testing.T) {
func TestDeferredExecutor_QueueSize(t *testing.T) {
t.Parallel()
test.SynctestTest(t, func(t *testing.T) {
synctest.Test(t, func(t *testing.T) {
logger := logtest.NewLoggerForTest(t)
e := NewDeferredExecutor(logger, 0)
defer e.waitForStop()

View file

@ -29,8 +29,6 @@ import (
"time"
"github.com/stretchr/testify/assert"
"github.com/strukturag/nextcloud-spreed-signaling/test"
)
func TestNotifierNoWaiter(t *testing.T) {
@ -120,7 +118,7 @@ func TestNotifierResetWillNotify(t *testing.T) {
func TestNotifierDuplicate(t *testing.T) {
t.Parallel()
test.SynctestTest(t, func(t *testing.T) {
synctest.Test(t, func(t *testing.T) {
var notifier Notifier
var done sync.WaitGroup

View file

@ -29,8 +29,6 @@ import (
"time"
"github.com/stretchr/testify/assert"
"github.com/strukturag/nextcloud-spreed-signaling/test"
)
func TestSingleNotifierNoWaiter(t *testing.T) {
@ -120,7 +118,7 @@ func TestSingleNotifierResetWillNotify(t *testing.T) {
func TestSingleNotifierDuplicate(t *testing.T) {
t.Parallel()
test.SynctestTest(t, func(t *testing.T) {
synctest.Test(t, func(t *testing.T) {
var notifier SingleNotifier
var done sync.WaitGroup

View file

@ -23,6 +23,7 @@ package async
import (
"testing"
"testing/synctest"
"time"
"github.com/stretchr/testify/assert"
@ -30,7 +31,6 @@ import (
"github.com/strukturag/nextcloud-spreed-signaling/log"
logtest "github.com/strukturag/nextcloud-spreed-signaling/log/test"
"github.com/strukturag/nextcloud-spreed-signaling/test"
)
func newMemoryThrottlerForTest(t *testing.T) Throttler {
@ -55,7 +55,7 @@ func expectDelay(t *testing.T, f func(), delay time.Duration) {
func TestThrottler(t *testing.T) {
t.Parallel()
test.SynctestTest(t, func(t *testing.T) {
synctest.Test(t, func(t *testing.T) {
assert := assert.New(t)
th := newMemoryThrottlerForTest(t)
@ -90,7 +90,7 @@ func TestThrottler(t *testing.T) {
func TestThrottlerIPv6(t *testing.T) {
t.Parallel()
test.SynctestTest(t, func(t *testing.T) {
synctest.Test(t, func(t *testing.T) {
assert := assert.New(t)
th := newMemoryThrottlerForTest(t)
@ -128,7 +128,7 @@ func TestThrottlerIPv6(t *testing.T) {
func TestThrottler_Bruteforce(t *testing.T) {
t.Parallel()
test.SynctestTest(t, func(t *testing.T) {
synctest.Test(t, func(t *testing.T) {
assert := assert.New(t)
th := newMemoryThrottlerForTest(t)
@ -155,7 +155,7 @@ func TestThrottler_Bruteforce(t *testing.T) {
func TestThrottler_Cleanup(t *testing.T) {
t.Parallel()
test.SynctestTest(t, func(t *testing.T) {
synctest.Test(t, func(t *testing.T) {
assert := assert.New(t)
throttler := newMemoryThrottlerForTest(t)
th, ok := throttler.(*memoryThrottler)
@ -212,7 +212,7 @@ func TestThrottler_Cleanup(t *testing.T) {
func TestThrottler_ExpirePartial(t *testing.T) {
t.Parallel()
test.SynctestTest(t, func(t *testing.T) {
synctest.Test(t, func(t *testing.T) {
assert := assert.New(t)
th := newMemoryThrottlerForTest(t)
@ -245,7 +245,7 @@ func TestThrottler_ExpirePartial(t *testing.T) {
func TestThrottler_ExpireAll(t *testing.T) {
t.Parallel()
test.SynctestTest(t, func(t *testing.T) {
synctest.Test(t, func(t *testing.T) {
assert := assert.New(t)
th := newMemoryThrottlerForTest(t)
@ -278,7 +278,7 @@ func TestThrottler_ExpireAll(t *testing.T) {
func TestThrottler_Negative(t *testing.T) {
t.Parallel()
test.SynctestTest(t, func(t *testing.T) {
synctest.Test(t, func(t *testing.T) {
assert := assert.New(t)
th := newMemoryThrottlerForTest(t)

View file

@ -36,6 +36,7 @@ import (
"sync"
"sync/atomic"
"testing"
"testing/synctest"
"time"
"github.com/dlintw/goconf"
@ -53,7 +54,6 @@ import (
"github.com/strukturag/nextcloud-spreed-signaling/proxy"
"github.com/strukturag/nextcloud-spreed-signaling/sfu"
"github.com/strukturag/nextcloud-spreed-signaling/talk"
"github.com/strukturag/nextcloud-spreed-signaling/test"
)
const (
@ -1705,7 +1705,7 @@ func TestProxyUnpublishRemoteOnSessionClose(t *testing.T) {
func TestExpireSessions(t *testing.T) {
t.Parallel()
test.SynctestTest(t, func(t *testing.T) {
synctest.Test(t, func(t *testing.T) {
assert := assert.New(t)
require := require.New(t)
proxyServer, key, server := newProxyServerForTest(t)

View file

@ -1,41 +0,0 @@
//go:build !go1.25
/**
* Standalone signaling server for the Nextcloud Spreed app.
* Copyright (C) 2025 struktur AG
*
* @author Joachim Bauch <bauch@struktur.de>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package test
import (
"testing"
"testing/synctest"
)
func SynctestTest(t *testing.T, f func(t *testing.T)) {
t.Helper()
synctest.Run(func() {
t.Run("synctest", func(t *testing.T) {
// synctest of Go 1.25 doesn't support "t.Parallel()" but we can't prevent
// this here. Invalid calls will be detected when running with Go 1.25.
f(t)
})
})
}

View file

@ -1,32 +0,0 @@
//go:build go1.25
/**
* Standalone signaling server for the Nextcloud Spreed app.
* Copyright (C) 2025 struktur AG
*
* @author Joachim Bauch <bauch@struktur.de>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package test
import (
"testing/synctest"
)
var (
SynctestTest = synctest.Test
)

View file

@ -1,38 +0,0 @@
/**
* Standalone signaling server for the Nextcloud Spreed app.
* Copyright (C) 2025 struktur AG
*
* @author Joachim Bauch <bauch@struktur.de>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package test
import (
"testing"
"time"
"github.com/stretchr/testify/assert"
)
func TestSynctest(t *testing.T) {
t.Parallel()
SynctestTest(t, func(t *testing.T) {
start := time.Now()
time.Sleep(time.Second)
assert.Equal(t, time.Second, time.Since(start))
})
}