Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
caddy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
caddy
Commits
6d493926
Commit
6d493926
authored
Jan 06, 2016
by
Matthew Holt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve tests, fix a few lint warnings
parent
45939820
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
12 additions
and
11 deletions
+12
-11
caddy/setup/startupshutdown_test.go
caddy/setup/startupshutdown_test.go
+7
-6
middleware/gzip/response_filter.go
middleware/gzip/response_filter.go
+2
-2
middleware/gzip/response_filter_test.go
middleware/gzip/response_filter_test.go
+1
-1
middleware/rewrite/condition.go
middleware/rewrite/condition.go
+1
-1
middleware/rewrite/rewrite.go
middleware/rewrite/rewrite.go
+1
-1
No files found.
caddy/setup/startupshutdown_test.go
View file @
6d493926
...
@@ -2,7 +2,6 @@ package setup
...
@@ -2,7 +2,6 @@ package setup
import
(
import
(
"os"
"os"
"os/exec"
"path/filepath"
"path/filepath"
"strconv"
"strconv"
"testing"
"testing"
...
@@ -13,16 +12,19 @@ import (
...
@@ -13,16 +12,19 @@ import (
// because the Startup and Shutdown functions share virtually the
// because the Startup and Shutdown functions share virtually the
// same functionality
// same functionality
func
TestStartup
(
t
*
testing
.
T
)
{
func
TestStartup
(
t
*
testing
.
T
)
{
tempDirPath
,
err
:=
getTempDirPath
()
tempDirPath
,
err
:=
getTempDirPath
()
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"BeforeTest: Failed to find an existing directory for testing! Error was: %v"
,
err
)
t
.
Fatalf
(
"BeforeTest: Failed to find an existing directory for testing! Error was: %v"
,
err
)
}
}
testDir
:=
filepath
.
Join
(
tempDirPath
,
"temp_dir_for_testing_startupshutdown.go"
)
testDir
:=
filepath
.
Join
(
tempDirPath
,
"temp_dir_for_testing_startupshutdown"
)
defer
func
()
{
// clean up after non-blocking startup function quits
time
.
Sleep
(
500
*
time
.
Millisecond
)
os
.
RemoveAll
(
testDir
)
}()
osSenitiveTestDir
:=
filepath
.
FromSlash
(
testDir
)
osSenitiveTestDir
:=
filepath
.
FromSlash
(
testDir
)
os
.
RemoveAll
(
osSenitiveTestDir
)
// start with a clean slate
exec
.
Command
(
"rm"
,
"-r"
,
osSenitiveTestDir
)
.
Run
()
// removes osSenitiveTestDir from the OS's temp directory, if the osSenitiveTestDir already exists
tests
:=
[]
struct
{
tests
:=
[]
struct
{
input
string
input
string
...
@@ -53,6 +55,5 @@ func TestStartup(t *testing.T) {
...
@@ -53,6 +55,5 @@ func TestStartup(t *testing.T) {
if
err
!=
nil
&&
!
test
.
shouldRemoveErr
{
if
err
!=
nil
&&
!
test
.
shouldRemoveErr
{
t
.
Errorf
(
"Test %d recieved an error of:
\n
%v"
,
i
,
err
)
t
.
Errorf
(
"Test %d recieved an error of:
\n
%v"
,
i
,
err
)
}
}
}
}
}
}
middleware/gzip/response_filter.go
View file @
6d493926
...
@@ -40,8 +40,8 @@ func NewResponseFilterWriter(filters []ResponseFilter, gz *gzipResponseWriter) *
...
@@ -40,8 +40,8 @@ func NewResponseFilterWriter(filters []ResponseFilter, gz *gzipResponseWriter) *
return
&
ResponseFilterWriter
{
filters
:
filters
,
gzipResponseWriter
:
gz
}
return
&
ResponseFilterWriter
{
filters
:
filters
,
gzipResponseWriter
:
gz
}
}
}
// Write
wraps underlying WriteHeader method and compresses if filters
// Write
Header wraps underlying WriteHeader method and
// are satisfied.
//
compresses if filters
are satisfied.
func
(
r
*
ResponseFilterWriter
)
WriteHeader
(
code
int
)
{
func
(
r
*
ResponseFilterWriter
)
WriteHeader
(
code
int
)
{
// Determine if compression should be used or not.
// Determine if compression should be used or not.
r
.
shouldCompress
=
true
r
.
shouldCompress
=
true
...
...
middleware/gzip/response_filter_test.go
View file @
6d493926
...
@@ -11,7 +11,7 @@ import (
...
@@ -11,7 +11,7 @@ import (
)
)
func
TestLengthFilter
(
t
*
testing
.
T
)
{
func
TestLengthFilter
(
t
*
testing
.
T
)
{
var
filters
[]
ResponseFilter
=
[]
ResponseFilter
{
var
filters
=
[]
ResponseFilter
{
LengthFilter
(
100
),
LengthFilter
(
100
),
LengthFilter
(
1000
),
LengthFilter
(
1000
),
LengthFilter
(
0
),
LengthFilter
(
0
),
...
...
middleware/rewrite/condition.go
View file @
6d493926
...
@@ -9,8 +9,8 @@ import (
...
@@ -9,8 +9,8 @@ import (
"github.com/mholt/caddy/middleware"
"github.com/mholt/caddy/middleware"
)
)
// Operators
const
(
const
(
// Operators
Is
=
"is"
Is
=
"is"
Not
=
"not"
Not
=
"not"
Has
=
"has"
Has
=
"has"
...
...
middleware/rewrite/rewrite.go
View file @
6d493926
...
@@ -76,7 +76,7 @@ type ComplexRule struct {
...
@@ -76,7 +76,7 @@ type ComplexRule struct {
*
regexp
.
Regexp
*
regexp
.
Regexp
}
}
// New
Regexp
Rule creates a new RegexpRule. It returns an error if regexp
// New
Complex
Rule creates a new RegexpRule. It returns an error if regexp
// pattern (pattern) or extensions (ext) are invalid.
// pattern (pattern) or extensions (ext) are invalid.
func
NewComplexRule
(
base
,
pattern
,
to
string
,
ext
[]
string
,
ifs
[]
If
)
(
*
ComplexRule
,
error
)
{
func
NewComplexRule
(
base
,
pattern
,
to
string
,
ext
[]
string
,
ifs
[]
If
)
(
*
ComplexRule
,
error
)
{
// validate regexp if present
// validate regexp if present
...
...
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