github.com/yaling888/clash@v1.53.0/component/script/matcher_test.go (about)

     1  package script
     2  
     3  import (
     4  	"fmt"
     5  	"testing"
     6  	"time"
     7  
     8  	"github.com/stretchr/testify/assert"
     9  
    10  	C "github.com/yaling888/clash/constant"
    11  )
    12  
    13  func TestSLNow(t *testing.T) {
    14  	now := time.Now()
    15  	hour := now.Hour()
    16  	minute := now.Minute()
    17  	second := now.Second()
    18  	code := fmt.Sprintf(`now.hour == %d and now.minute == %d and now.second == %d`, hour, minute, second)
    19  	m, err := NewMatcher("test", "test", code)
    20  	assert.NoError(t, err)
    21  
    22  	v, err := m.Match(&C.Metadata{})
    23  	assert.NoError(t, err)
    24  	assert.True(t, v)
    25  }