2022-08-03 14:55:48 +00:00
|
|
|
package owl_test
|
2022-07-21 17:44:07 +00:00
|
|
|
|
2022-07-24 14:19:21 +00:00
|
|
|
import (
|
2022-08-03 14:55:48 +00:00
|
|
|
"h4kor/owl-blogs"
|
2022-07-24 14:19:21 +00:00
|
|
|
"math/rand"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
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()
|
|
|
|
}
|
2022-07-21 17:44:07 +00:00
|
|
|
|
2022-08-03 14:55:48 +00:00
|
|
|
func getTestUser() owl.User {
|
|
|
|
repo, _ := owl.CreateRepository(testRepoName())
|
2022-07-21 17:44:07 +00:00
|
|
|
user, _ := repo.CreateUser(randomUserName())
|
|
|
|
return user
|
|
|
|
}
|
2022-07-23 15:19:47 +00:00
|
|
|
|
2022-08-03 14:55:48 +00:00
|
|
|
func getTestRepo() owl.Repository {
|
|
|
|
repo, _ := owl.CreateRepository(testRepoName())
|
2022-07-24 18:29:31 +00:00
|
|
|
return repo
|
|
|
|
}
|
|
|
|
|
2022-07-23 15:19:47 +00:00
|
|
|
func contains(s []string, e string) bool {
|
|
|
|
for _, a := range s {
|
|
|
|
if a == e {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|