Markdown: Watch for file changes. Removed sitegen dependency for links.

This commit is contained in:
Abiola Ibrahim
2015-08-04 23:35:09 +01:00
parent 32da2ed706
commit 851026d3fa
8 changed files with 205 additions and 26 deletions

View 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)
}
}