github.com/TeaOSLab/EdgeNode@v1.3.8/internal/waf/action_utils_test.go (about)

     1  package waf_test
     2  
     3  import (
     4  	"github.com/TeaOSLab/EdgeNode/internal/waf"
     5  	"github.com/iwind/TeaGo/assert"
     6  	"github.com/iwind/TeaGo/logs"
     7  	"github.com/iwind/TeaGo/maps"
     8  	"runtime"
     9  	"testing"
    10  )
    11  
    12  func TestFindActionInstance(t *testing.T) {
    13  	a := assert.NewAssertion(t)
    14  
    15  	t.Logf("ActionBlock: %p", waf.FindActionInstance(waf.ActionBlock, nil))
    16  	t.Logf("ActionBlock: %p", waf.FindActionInstance(waf.ActionBlock, nil))
    17  	t.Logf("ActionGoGroup: %p", waf.FindActionInstance(waf.ActionGoGroup, nil))
    18  	t.Logf("ActionGoGroup: %p", waf.FindActionInstance(waf.ActionGoGroup, nil))
    19  	t.Logf("ActionGoSet: %p", waf.FindActionInstance(waf.ActionGoSet, nil))
    20  	t.Logf("ActionGoSet: %p", waf.FindActionInstance(waf.ActionGoSet, nil))
    21  	t.Logf("ActionGoSet: %#v", waf.FindActionInstance(waf.ActionGoSet, maps.Map{"groupId": "a", "setId": "b"}))
    22  
    23  	a.IsTrue(waf.FindActionInstance(waf.ActionGoSet, nil) != waf.FindActionInstance(waf.ActionGoSet, nil))
    24  }
    25  
    26  func TestFindActionInstance_Options(t *testing.T) {
    27  	//t.Logf("%p", FindActionInstance(ActionBlock, maps.Map{}))
    28  	//t.Logf("%p", FindActionInstance(ActionBlock, maps.Map{}))
    29  	//logs.PrintAsJSON(FindActionInstance(ActionBlock, maps.Map{}), t)
    30  	logs.PrintAsJSON(waf.FindActionInstance(waf.ActionBlock, maps.Map{
    31  		"timeout": 3600,
    32  	}), t)
    33  }
    34  
    35  func BenchmarkFindActionInstance(b *testing.B) {
    36  	runtime.GOMAXPROCS(1)
    37  	for i := 0; i < b.N; i++ {
    38  		waf.FindActionInstance(waf.ActionGoSet, nil)
    39  	}
    40  }