Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
C
Coredns
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Railgun
Coredns
Commits
e4170150
Commit
e4170150
authored
Sep 09, 2017
by
Miek Gieben
Committed by
GitHub
Sep 09, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mw/secondary: more tests in setup_test.go (#1039)
Improve the syntax tests for this middleware.
parent
8e5d0a23
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
3 deletions
+27
-3
middleware/secondary/setup_test.go
middleware/secondary/setup_test.go
+27
-3
No files found.
middleware/secondary/setup_test.go
View file @
e4170150
...
@@ -6,17 +6,18 @@ import (
...
@@ -6,17 +6,18 @@ import (
"github.com/mholt/caddy"
"github.com/mholt/caddy"
)
)
// TODO(miek): this only check the syntax.
func
TestSecondaryParse
(
t
*
testing
.
T
)
{
func
TestSecondaryParse
(
t
*
testing
.
T
)
{
tests
:=
[]
struct
{
tests
:=
[]
struct
{
inputFileRules
string
inputFileRules
string
shouldErr
bool
shouldErr
bool
transferFrom
string
transferFrom
string
zones
[]
string
}{
}{
{
{
`secondary`
,
`secondary`
,
false
,
// TODO(miek): should actually be true, because without transfer lines this does not make sense
false
,
// TODO(miek): should actually be true, because without transfer lines this does not make sense
""
,
""
,
nil
,
},
},
{
{
`secondary {
`secondary {
...
@@ -24,18 +25,41 @@ func TestSecondaryParse(t *testing.T) {
...
@@ -24,18 +25,41 @@ func TestSecondaryParse(t *testing.T) {
transfer to 127.0.0.1
transfer to 127.0.0.1
}`
,
}`
,
false
,
false
,
""
,
"127.0.0.1:53"
,
nil
,
},
{
`secondary example.org {
transfer from 127.0.0.1
transfer to 127.0.0.1
}`
,
false
,
"127.0.0.1:53"
,
[]
string
{
"example.org."
},
},
},
}
}
for
i
,
test
:=
range
tests
{
for
i
,
test
:=
range
tests
{
c
:=
caddy
.
NewTestController
(
"dns"
,
test
.
inputFileRules
)
c
:=
caddy
.
NewTestController
(
"dns"
,
test
.
inputFileRules
)
_
,
err
:=
secondaryParse
(
c
)
s
,
err
:=
secondaryParse
(
c
)
if
err
==
nil
&&
test
.
shouldErr
{
if
err
==
nil
&&
test
.
shouldErr
{
t
.
Fatalf
(
"Test %d expected errors, but got no error"
,
i
)
t
.
Fatalf
(
"Test %d expected errors, but got no error"
,
i
)
}
else
if
err
!=
nil
&&
!
test
.
shouldErr
{
}
else
if
err
!=
nil
&&
!
test
.
shouldErr
{
t
.
Fatalf
(
"Test %d expected no errors, but got '%v'"
,
i
,
err
)
t
.
Fatalf
(
"Test %d expected no errors, but got '%v'"
,
i
,
err
)
}
}
for
i
,
name
:=
range
test
.
zones
{
if
x
:=
s
.
Names
[
i
];
x
!=
name
{
t
.
Fatalf
(
"Test %d zone names don't match expected %q, but got %q"
,
i
,
name
,
x
)
}
}
// This is only set *iff* we have a zone (i.e. not in all tests above)
for
_
,
v
:=
range
s
.
Z
{
if
x
:=
v
.
TransferFrom
[
0
];
x
!=
test
.
transferFrom
{
t
.
Fatalf
(
"Test %d transform from names don't match expected %q, but got %q"
,
i
,
test
.
transferFrom
,
x
)
}
}
}
}
}
}
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