mirror of
https://github.com/vbatts/sl-feeds.git
synced 2024-11-15 20:58:38 +00:00
Vincent Batts
ce788fcd88
and get its remote last-modified time Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
36 lines
683 B
Go
36 lines
683 B
Go
package fetch
|
|
|
|
import (
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"os"
|
|
"testing"
|
|
)
|
|
|
|
func TestFetchChangeLog(t *testing.T) {
|
|
server := httptest.NewServer(http.FileServer(http.Dir("../changelog/testdata/")))
|
|
defer server.Close()
|
|
|
|
r := Repo{
|
|
URL: server.URL,
|
|
}
|
|
|
|
e, mtime, err := r.ChangeLog()
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
expectedLen := 52
|
|
if len(e) != expectedLen {
|
|
t.Errorf("expected %d entries; got %d", expectedLen, len(e))
|
|
}
|
|
|
|
stat, err := os.Stat("../changelog/testdata/ChangeLog.txt")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
if mtime.Unix() != stat.ModTime().Unix() {
|
|
t.Errorf("time stamps not the same: expected %d; got %d", stat.ModTime().Unix(), mtime.Unix())
|
|
}
|
|
}
|