github.com/TeaOSLab/EdgeNode@v1.3.8/internal/iplibrary/action_manager_test.go (about)

     1  package iplibrary
     2  
     3  import (
     4  	"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs"
     5  	"github.com/iwind/TeaGo/maps"
     6  	"testing"
     7  )
     8  
     9  func TestActionManager_UpdateActions(t *testing.T) {
    10  	var manager = NewActionManager()
    11  	manager.UpdateActions([]*firewallconfigs.FirewallActionConfig{
    12  		{
    13  			Id:   1,
    14  			Type: "ipset",
    15  			Params: maps.Map{
    16  				"whiteName": "edge-white-list",
    17  				"blackName": "edge-black-list",
    18  			},
    19  		},
    20  	})
    21  	t.Log("===config===")
    22  	for _, c := range manager.configMap {
    23  		t.Log(c.Id, c.Type)
    24  	}
    25  	t.Log("===instance===")
    26  	for id, c := range manager.instanceMap {
    27  		t.Log(id, c)
    28  	}
    29  
    30  	manager.UpdateActions([]*firewallconfigs.FirewallActionConfig{
    31  		{
    32  			Id:   1,
    33  			Type: "ipset",
    34  			Params: maps.Map{
    35  				"whiteName": "edge-white-list",
    36  				"blackName": "edge-black-list",
    37  			},
    38  		},
    39  		{
    40  			Id:   2,
    41  			Type: "iptables",
    42  			Params: maps.Map{
    43  			},
    44  		},
    45  	})
    46  
    47  	t.Log("===config===")
    48  	for _, c := range manager.configMap {
    49  		t.Log(c.Id, c.Type)
    50  	}
    51  	t.Log("===instance===")
    52  	for id, c := range manager.instanceMap {
    53  		t.Logf("%d: %#v", id, c)
    54  	}
    55  
    56  }