2017-01-26 23:47:54 +00:00
|
|
|
package fetch
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
"net/http/httptest"
|
|
|
|
"os"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestFetchChangeLog(t *testing.T) {
|
2017-02-27 13:57:04 +00:00
|
|
|
server := httptest.NewServer(http.FileServer(http.Dir("../changelog/testdata/slackware64/")))
|
2017-01-26 23:47:54 +00:00
|
|
|
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))
|
|
|
|
}
|
|
|
|
|
2017-02-27 13:57:04 +00:00
|
|
|
stat, err := os.Stat("../changelog/testdata/slackware64/ChangeLog.txt")
|
2017-01-26 23:47:54 +00:00
|
|
|
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())
|
|
|
|
}
|
|
|
|
}
|