diff --git a/caddy/setup/startupshutdown_test.go b/caddy/setup/startupshutdown_test.go index a6bdf1b7..16fa973c 100644 --- a/caddy/setup/startupshutdown_test.go +++ b/caddy/setup/startupshutdown_test.go @@ -2,7 +2,6 @@ package setup import ( "os" - "os/exec" "path/filepath" "strconv" "testing" @@ -13,16 +12,19 @@ import ( // because the Startup and Shutdown functions share virtually the // same functionality func TestStartup(t *testing.T) { - tempDirPath, err := getTempDirPath() if err != nil { 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) - - exec.Command("rm", "-r", osSenitiveTestDir).Run() // removes osSenitiveTestDir from the OS's temp directory, if the osSenitiveTestDir already exists + os.RemoveAll(osSenitiveTestDir) // start with a clean slate tests := []struct { input string @@ -53,6 +55,5 @@ func TestStartup(t *testing.T) { if err != nil && !test.shouldRemoveErr { t.Errorf("Test %d recieved an error of:\n%v", i, err) } - } } diff --git a/middleware/gzip/response_filter.go b/middleware/gzip/response_filter.go index b561649e..3039eb9e 100644 --- a/middleware/gzip/response_filter.go +++ b/middleware/gzip/response_filter.go @@ -40,8 +40,8 @@ func NewResponseFilterWriter(filters []ResponseFilter, gz *gzipResponseWriter) * return &ResponseFilterWriter{filters: filters, gzipResponseWriter: gz} } -// Write wraps underlying WriteHeader method and compresses if filters -// are satisfied. +// WriteHeader wraps underlying WriteHeader method and +// compresses if filters are satisfied. func (r *ResponseFilterWriter) WriteHeader(code int) { // Determine if compression should be used or not. r.shouldCompress = true diff --git a/middleware/gzip/response_filter_test.go b/middleware/gzip/response_filter_test.go index 75f72692..2878336c 100644 --- a/middleware/gzip/response_filter_test.go +++ b/middleware/gzip/response_filter_test.go @@ -11,7 +11,7 @@ import ( ) func TestLengthFilter(t *testing.T) { - var filters []ResponseFilter = []ResponseFilter{ + var filters = []ResponseFilter{ LengthFilter(100), LengthFilter(1000), LengthFilter(0), diff --git a/middleware/rewrite/condition.go b/middleware/rewrite/condition.go index c863af4f..1ec64749 100644 --- a/middleware/rewrite/condition.go +++ b/middleware/rewrite/condition.go @@ -9,8 +9,8 @@ import ( "github.com/mholt/caddy/middleware" ) +// Operators const ( - // Operators Is = "is" Not = "not" Has = "has" diff --git a/middleware/rewrite/rewrite.go b/middleware/rewrite/rewrite.go index 60cc0b9d..9b61f0fc 100644 --- a/middleware/rewrite/rewrite.go +++ b/middleware/rewrite/rewrite.go @@ -76,7 +76,7 @@ type ComplexRule struct { *regexp.Regexp } -// NewRegexpRule creates a new RegexpRule. It returns an error if regexp +// NewComplexRule creates a new RegexpRule. It returns an error if regexp // pattern (pattern) or extensions (ext) are invalid. func NewComplexRule(base, pattern, to string, ext []string, ifs []If) (*ComplexRule, error) { // validate regexp if present