1
0
Fork 0
mirror of https://github.com/eosswedenorg/thalos synced 2026-06-16 04:24:56 +02:00

internal/types/blacklist.go: adding Empty()

This commit is contained in:
Henrik Hautakoski 2024-07-15 22:57:05 +02:00
parent cbd3196cf9
commit 0aee0a97aa
2 changed files with 14 additions and 0 deletions

View file

@ -2,6 +2,10 @@ package types
type Blacklist map[string][]string
func (bl Blacklist) Empty() bool {
return len(bl) < 1
}
func (bl Blacklist) Add(contract string, action string) {
if len(bl[contract]) < 1 {
bl[contract] = []string{}

View file

@ -6,6 +6,16 @@ import (
"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) {
bl := Blacklist{}
bl.Add("contract", "action1")