mirror of
https://github.com/eosswedenorg/thalos
synced 2026-08-23 19:48:12 +02:00
internal/types/blacklist.go: adding Empty()
This commit is contained in:
parent
cbd3196cf9
commit
0aee0a97aa
2 changed files with 14 additions and 0 deletions
|
|
@ -2,6 +2,10 @@ package types
|
||||||
|
|
||||||
type Blacklist map[string][]string
|
type Blacklist map[string][]string
|
||||||
|
|
||||||
|
func (bl Blacklist) Empty() bool {
|
||||||
|
return len(bl) < 1
|
||||||
|
}
|
||||||
|
|
||||||
func (bl Blacklist) Add(contract string, action string) {
|
func (bl Blacklist) Add(contract string, action string) {
|
||||||
if len(bl[contract]) < 1 {
|
if len(bl[contract]) < 1 {
|
||||||
bl[contract] = []string{}
|
bl[contract] = []string{}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,16 @@ import (
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func TestBlacklist_Empty(t *testing.T) {
|
||||||
|
bl := Blacklist{}
|
||||||
|
|
||||||
|
require.True(t, bl.Empty())
|
||||||
|
|
||||||
|
bl.Add("contract", "action1")
|
||||||
|
|
||||||
|
require.False(t, bl.Empty())
|
||||||
|
}
|
||||||
|
|
||||||
func TestBlacklist_Add(t *testing.T) {
|
func TestBlacklist_Add(t *testing.T) {
|
||||||
bl := Blacklist{}
|
bl := Blacklist{}
|
||||||
bl.Add("contract", "action1")
|
bl.Add("contract", "action1")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue