-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmanager_test.go
More file actions
36 lines (30 loc) · 841 Bytes
/
manager_test.go
File metadata and controls
36 lines (30 loc) · 841 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Copyright 2021 Flamego. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package session
import (
"context"
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestIsValidSessionID(t *testing.T) {
for i := 0; i < 10; i++ {
s, err := randomChars(16)
require.Nil(t, err)
assert.True(t, isValidSessionID(s, 16))
}
assert.False(t, isValidSessionID("123", 16))
assert.False(t, isValidSessionID("3qKCBYmuAqG1RQix", 16))
assert.False(t, isValidSessionID("../session/ad2c7", 16))
}
func TestManager_startGC(t *testing.T) {
m := newManager(newMemoryStore(MemoryConfig{}, nil))
stop := m.startGC(
context.Background(),
time.Minute,
func(error) { panic("unreachable") },
)
stop <- struct{}{}
}