Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
origosys
External Dns
Commits
4b1082ea
Commit
4b1082ea
authored
6 years ago
by
Curtis Mattoon
Browse files
Options
Download
Email Patches
Plain Diff
Add tests for provider/domain_filter
parent
e23513ee
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
0 deletions
+32
-0
provider/domain_filter_test.go
provider/domain_filter_test.go
+32
-0
No files found.
provider/domain_filter_test.go
View file @
4b1082ea
...
...
@@ -226,3 +226,35 @@ func TestDomainFilterMatchWithEmptyFilter(t *testing.T) {
}
}
}
func
TestPrepareFiltersStripsWhitespaceAndDotSuffix
(
t
*
testing
.
T
)
{
for
_
,
tt
:=
range
[]
struct
{
input
[]
string
output
[]
string
}{
{
[]
string
{
" "
,
" "
,
""
},
[]
string
{
""
,
""
,
""
},
},
{
[]
string
{
" foo "
,
" bar. "
,
"baz."
},
[]
string
{
"foo"
,
"bar"
,
"baz"
},
},
{
[]
string
{
"foo.bar"
,
" foo.bar. "
,
" foo.bar.baz "
,
" foo.bar.baz. "
},
[]
string
{
"foo.bar"
,
"foo.bar"
,
"foo.bar.baz"
,
"foo.bar.baz"
},
},
}
{
t
.
Run
(
"test string"
,
func
(
t
*
testing
.
T
)
{
assert
.
Equal
(
t
,
tt
.
output
,
prepareFilters
(
tt
.
input
))
})
}
}
func
TestMatchFilterReturnsProperEmptyVal
(
t
*
testing
.
T
)
{
emptyFilters
:=
[]
string
{}
df
:=
NewDomainFilterWithExclusions
(
emptyFilters
,
emptyFilters
)
assert
.
Equal
(
t
,
true
,
df
.
matchFilter
(
emptyFilters
,
"somedomain.com"
,
true
))
assert
.
Equal
(
t
,
false
,
df
.
matchFilter
(
emptyFilters
,
"somedomain.com"
,
false
))
}
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment