diff options
| author | radhitya <alif@radhitya.org> | 2026-06-14 18:48:28 +0700 |
|---|---|---|
| committer | radhitya <alif@radhitya.org> | 2026-06-14 18:48:28 +0700 |
| commit | 61be9c66887fceeaa998471aa2a28c49c1f11b3c (patch) | |
| tree | cf224ced58892b8a3d3678653455ffbfd501a02a /internal/blocklist/blocklist_test.go | |
| parent | a8df5f3b6d18371b8c4cc98d01f4004586a50b21 (diff) | |
ubah cara mainnya ad blocker
Diffstat (limited to 'internal/blocklist/blocklist_test.go')
| -rw-r--r-- | internal/blocklist/blocklist_test.go | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/internal/blocklist/blocklist_test.go b/internal/blocklist/blocklist_test.go index 9ae1749..b6d4e83 100644 --- a/internal/blocklist/blocklist_test.go +++ b/internal/blocklist/blocklist_test.go @@ -7,9 +7,14 @@ import ( ) func TestBlockZeroIP(t *testing.T) { +dir := t.TempDir() + p := filepath.Join(dir, "block.txt") + os.WriteFile(p, []byte("||example.com^\n0.0.0.0 doubleclick.net\n"), 0644) + b := New(ResponseZeroIP) - b.addRule("||example.com^") - b.addRule("0.0.0.0 doubleclick.net") + if err := b.LoadFile(p); err != nil { + t.Fatal(err) + } cases := []struct { domain string @@ -29,11 +34,15 @@ func TestBlockZeroIP(t *testing.T) { } } } - func TestException(t *testing.T) { + dir := t.TempDir() + p := filepath.Join(dir, "block.txt") + os.WriteFile(p, []byte("||example.com^\n@@||whitelist.example.com^\n"), 0644) + b := New(ResponseZeroIP) - b.addRule("||example.com^") - b.addRule("@@||whitelist.example.com^") + if err := b.LoadFile(p); err != nil { + t.Fatal(err) + } if !b.IsBlocked("example.com.") { t.Error("expected blocked") @@ -45,7 +54,6 @@ func TestException(t *testing.T) { t.Error("expected NOT blocked (exception subdomain)") } } - func TestLoadFile(t *testing.T) { dir := t.TempDir() p := filepath.Join(dir, "block.txt") |
