mirror of
https://github.com/livekit/livekit.git
synced 2026-03-31 21:55:41 +00:00
33 lines
615 B
Go
33 lines
615 B
Go
package selector_test
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/livekit/protocol/livekit"
|
|
|
|
"github.com/livekit/livekit-server/pkg/routing/selector"
|
|
)
|
|
|
|
func TestIsAvailable(t *testing.T) {
|
|
t.Run("still available", func(t *testing.T) {
|
|
n := &livekit.Node{
|
|
Stats: &livekit.NodeStats{
|
|
UpdatedAt: time.Now().Unix() - 3,
|
|
},
|
|
}
|
|
require.True(t, selector.IsAvailable(n))
|
|
})
|
|
|
|
t.Run("expired", func(t *testing.T) {
|
|
n := &livekit.Node{
|
|
Stats: &livekit.NodeStats{
|
|
UpdatedAt: time.Now().Unix() - 20,
|
|
},
|
|
}
|
|
require.False(t, selector.IsAvailable(n))
|
|
})
|
|
}
|