58 lines
1.0 KiB
Go
58 lines
1.0 KiB
Go
package owl_test
|
|
|
|
import (
|
|
"h4kor/owl-blogs"
|
|
"math/rand"
|
|
"time"
|
|
)
|
|
|
|
type MockMicroformatParser struct{}
|
|
|
|
func (*MockMicroformatParser) ParseHEntry(data []byte) (owl.ParsedHEntry, error) {
|
|
return owl.ParsedHEntry{Title: "Mock Title"}, nil
|
|
}
|
|
|
|
type MockHttpRetriever struct{}
|
|
|
|
func (*MockHttpRetriever) Get(url string) ([]byte, error) {
|
|
return []byte(""), nil
|
|
}
|
|
|
|
func randomName() string {
|
|
rand.Seed(time.Now().UnixNano())
|
|
var letters = []rune("abcdefghijklmnopqrstuvwxyz")
|
|
b := make([]rune, 8)
|
|
for i := range b {
|
|
b[i] = letters[rand.Intn(len(letters))]
|
|
}
|
|
return string(b)
|
|
}
|
|
|
|
func testRepoName() string {
|
|
return "/tmp/" + randomName()
|
|
}
|
|
|
|
func randomUserName() string {
|
|
return randomName()
|
|
}
|
|
|
|
func getTestUser() owl.User {
|
|
repo, _ := owl.CreateRepository(testRepoName())
|
|
user, _ := repo.CreateUser(randomUserName())
|
|
return user
|
|
}
|
|
|
|
func getTestRepo() owl.Repository {
|
|
repo, _ := owl.CreateRepository(testRepoName())
|
|
return repo
|
|
}
|
|
|
|
func contains(s []string, e string) bool {
|
|
for _, a := range s {
|
|
if a == e {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|