mirror of
https://github.com/strukturag/nextcloud-spreed-signaling
synced 2026-03-14 14:35:44 +01:00
Move test storage to "test" package.
This commit is contained in:
parent
ee6f026bbb
commit
a4631a19cf
4 changed files with 13 additions and 13 deletions
|
|
@ -27,8 +27,8 @@ import (
|
|||
"sync"
|
||||
"testing"
|
||||
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/internal"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/log"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/test"
|
||||
)
|
||||
|
||||
type testLogWriter struct {
|
||||
|
|
@ -47,7 +47,7 @@ func (w *testLogWriter) Write(b []byte) (int, error) {
|
|||
}
|
||||
|
||||
var (
|
||||
testLoggers internal.TestStorage[log.Logger]
|
||||
testLoggers test.Storage[log.Logger]
|
||||
)
|
||||
|
||||
func NewLoggerForTest(t testing.TB) log.Logger {
|
||||
|
|
|
|||
|
|
@ -553,7 +553,7 @@ func processSessionRequest(t *testing.T, w http.ResponseWriter, r *http.Request,
|
|||
}
|
||||
|
||||
var (
|
||||
pingRequests internal.TestStorage[[]*talk.BackendClientRequest]
|
||||
pingRequests test.Storage[[]*talk.BackendClientRequest]
|
||||
)
|
||||
|
||||
func getPingRequests(t *testing.T) []*talk.BackendClientRequest {
|
||||
|
|
@ -599,7 +599,7 @@ type testAuthToken struct {
|
|||
}
|
||||
|
||||
var (
|
||||
authTokens internal.TestStorage[testAuthToken]
|
||||
authTokens test.Storage[testAuthToken]
|
||||
)
|
||||
|
||||
func ensureAuthTokens(t *testing.T) (string, string) {
|
||||
|
|
@ -708,7 +708,7 @@ func registerBackendHandler(t *testing.T, router *mux.Router) {
|
|||
}
|
||||
|
||||
var (
|
||||
skipV2Capabilities internal.TestStorage[bool]
|
||||
skipV2Capabilities test.Storage[bool]
|
||||
)
|
||||
|
||||
func registerBackendHandlerUrl(t *testing.T, router *mux.Router, url string) {
|
||||
|
|
|
|||
|
|
@ -19,20 +19,20 @@
|
|||
* 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 internal
|
||||
package test
|
||||
|
||||
import (
|
||||
"sync"
|
||||
"testing"
|
||||
)
|
||||
|
||||
type TestStorage[T any] struct {
|
||||
type Storage[T any] struct {
|
||||
mu sync.Mutex
|
||||
// +checklocks:mu
|
||||
entries map[string]T // +checklocksignore: Not supported yet, see https://github.com/google/gvisor/issues/11671
|
||||
}
|
||||
|
||||
func (s *TestStorage[T]) cleanup(key string) {
|
||||
func (s *Storage[T]) cleanup(key string) {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
|
||||
|
|
@ -42,7 +42,7 @@ func (s *TestStorage[T]) cleanup(key string) {
|
|||
}
|
||||
}
|
||||
|
||||
func (s *TestStorage[T]) Set(tb testing.TB, value T) {
|
||||
func (s *Storage[T]) Set(tb testing.TB, value T) {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
|
||||
|
|
@ -59,7 +59,7 @@ func (s *TestStorage[T]) Set(tb testing.TB, value T) {
|
|||
s.entries[key] = value
|
||||
}
|
||||
|
||||
func (s *TestStorage[T]) Get(tb testing.TB) (T, bool) {
|
||||
func (s *Storage[T]) Get(tb testing.TB) (T, bool) {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
|
||||
|
|
@ -72,7 +72,7 @@ func (s *TestStorage[T]) Get(tb testing.TB) (T, bool) {
|
|||
return defaultValue, false
|
||||
}
|
||||
|
||||
func (s *TestStorage[T]) Del(tb testing.TB) {
|
||||
func (s *Storage[T]) Del(tb testing.TB) {
|
||||
key := tb.Name()
|
||||
s.cleanup(key)
|
||||
}
|
||||
|
|
@ -19,7 +19,7 @@
|
|||
* 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 internal
|
||||
package test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
|
@ -30,7 +30,7 @@ import (
|
|||
func Test_TestStorage(t *testing.T) {
|
||||
t.Parallel()
|
||||
assert := assert.New(t)
|
||||
var storage TestStorage[int]
|
||||
var storage Storage[int]
|
||||
|
||||
t.Cleanup(func() {
|
||||
storage.mu.Lock()
|
||||
Loading…
Add table
Add a link
Reference in a new issue