diff options
| author | copilot-swe-agent[bot] <[email protected]> | 2025-11-14 08:36:12 +0000 |
|---|---|---|
| committer | copilot-swe-agent[bot] <[email protected]> | 2025-11-14 08:36:12 +0000 |
| commit | ea4f75a68465992c68779fc0cc4ea3ef251af05e (patch) | |
| tree | fa8104a0377e3f7810953301803bfc0bfcba35be /lib/lib_test.go | |
| parent | be5f580e8bfb9169bb8b410d1e154057e9ac1ed5 (diff) | |
Add comprehensive unit tests for lib package with 90.3% coveragecopilot/add-unit-tests-for-lib-package
Co-authored-by: Loyalsoldier <[email protected]>
Diffstat (limited to 'lib/lib_test.go')
| -rw-r--r-- | lib/lib_test.go | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/lib/lib_test.go b/lib/lib_test.go new file mode 100644 index 00000000..dabed27e --- /dev/null +++ b/lib/lib_test.go @@ -0,0 +1,66 @@ +package lib + +import "testing" + +func TestConstants(t *testing.T) { + tests := []struct { + name string + action Action + expected bool + }{ + {"ActionAdd in registry", ActionAdd, true}, + {"ActionRemove in registry", ActionRemove, true}, + {"ActionOutput in registry", ActionOutput, true}, + {"Invalid action not in registry", Action("invalid"), false}, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := ActionsRegistry[tt.action]; got != tt.expected { + t.Errorf("ActionsRegistry[%s] = %v, want %v", tt.action, got, tt.expected) + } + }) + } +} + +func TestActionConstants(t *testing.T) { + if ActionAdd != "add" { + t.Errorf("ActionAdd = %s, want 'add'", ActionAdd) + } + if ActionRemove != "remove" { + t.Errorf("ActionRemove = %s, want 'remove'", ActionRemove) + } + if ActionOutput != "output" { + t.Errorf("ActionOutput = %s, want 'output'", ActionOutput) + } +} + +func TestIPTypeConstants(t *testing.T) { + if IPv4 != "ipv4" { + t.Errorf("IPv4 = %s, want 'ipv4'", IPv4) + } + if IPv6 != "ipv6" { + t.Errorf("IPv6 = %s, want 'ipv6'", IPv6) + } +} + +func TestCaseRemoveConstants(t *testing.T) { + if CaseRemovePrefix != 0 { + t.Errorf("CaseRemovePrefix = %d, want 0", CaseRemovePrefix) + } + if CaseRemoveEntry != 1 { + t.Errorf("CaseRemoveEntry = %d, want 1", CaseRemoveEntry) + } +} + +func TestIgnoreIPv4(t *testing.T) { + if got := IgnoreIPv4(); got != IPv4 { + t.Errorf("IgnoreIPv4() = %v, want %v", got, IPv4) + } +} + +func TestIgnoreIPv6(t *testing.T) { + if got := IgnoreIPv6(); got != IPv6 { + t.Errorf("IgnoreIPv6() = %v, want %v", got, IPv6) + } +} |
