mirror of
https://github.com/caddyserver/caddy.git
synced 2025-05-28 14:45:49 +08:00
Markdown: Watch for file changes. Removed sitegen dependency for links.
This commit is contained in:
34
middleware/markdown/watcher_test.go
Normal file
34
middleware/markdown/watcher_test.go
Normal file
@ -0,0 +1,34 @@
|
||||
package markdown
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestWatcher(t *testing.T) {
|
||||
expected := "12345678"
|
||||
interval := time.Millisecond * 100
|
||||
i := 0
|
||||
out := ""
|
||||
stopChan := TickerFunc(interval, func() {
|
||||
i++
|
||||
out += fmt.Sprint(i)
|
||||
})
|
||||
time.Sleep(interval * 8)
|
||||
stopChan <- struct{}{}
|
||||
if expected != out {
|
||||
t.Fatalf("Expected %v, found %v", expected, out)
|
||||
}
|
||||
out = ""
|
||||
i = 0
|
||||
stopChan = TickerFunc(interval, func() {
|
||||
i++
|
||||
out += fmt.Sprint(i)
|
||||
})
|
||||
time.Sleep(interval * 10)
|
||||
if !strings.HasPrefix(out, expected) || out == expected {
|
||||
t.Fatalf("expected (%v) must be a proper prefix of out(%v).", expected, out)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user