renaming to owl-blogs
This commit is contained in:
parent
c0b4c01aba
commit
e657b69f50
|
@ -1,12 +1,12 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"h4kor/kiss-social"
|
"h4kor/owl-blogs"
|
||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
println("KISS Social")
|
println("owl blogs")
|
||||||
println("Commands")
|
println("Commands")
|
||||||
println("init <repo> - Creates a new repository")
|
println("init <repo> - Creates a new repository")
|
||||||
println("<repo> new-user <name> - Creates a new user")
|
println("<repo> new-user <name> - Creates a new user")
|
||||||
|
@ -19,7 +19,7 @@ func main() {
|
||||||
|
|
||||||
if os.Args[1] == "init" {
|
if os.Args[1] == "init" {
|
||||||
repoName := os.Args[2]
|
repoName := os.Args[2]
|
||||||
_, err := kiss.CreateRepository(repoName)
|
_, err := owl.CreateRepository(repoName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
println("Error creating repository: ", err.Error())
|
println("Error creating repository: ", err.Error())
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
repoName := os.Args[1]
|
repoName := os.Args[1]
|
||||||
repo, err := kiss.OpenRepository(repoName)
|
repo, err := owl.OpenRepository(repoName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
println("Error opening repository: ", err.Error())
|
println("Error opening repository: ", err.Error())
|
||||||
os.Exit(1)
|
os.Exit(1)
|
|
@ -1,7 +1,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"h4kor/kiss-social"
|
"h4kor/owl-blogs"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
@ -9,7 +9,7 @@ import (
|
||||||
"github.com/julienschmidt/httprouter"
|
"github.com/julienschmidt/httprouter"
|
||||||
)
|
)
|
||||||
|
|
||||||
// func handler(repo kiss.Repository) func(http.ResponseWriter, *http.Request) {
|
// func handler(repo owl.Repository) func(http.ResponseWriter, *http.Request) {
|
||||||
// return func(w http.ResponseWriter, r *http.Request) {
|
// return func(w http.ResponseWriter, r *http.Request) {
|
||||||
// // normalize the path
|
// // normalize the path
|
||||||
// path := r.URL.Path
|
// path := r.URL.Path
|
||||||
|
@ -48,9 +48,9 @@ import (
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
func indexHandler(repo kiss.Repository) func(http.ResponseWriter, *http.Request, httprouter.Params) {
|
func indexHandler(repo owl.Repository) func(http.ResponseWriter, *http.Request, httprouter.Params) {
|
||||||
return func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
|
return func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
|
||||||
html, err := kiss.RenderUserList(repo)
|
html, err := owl.RenderUserList(repo)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
println("Error rendering index: ", err.Error())
|
println("Error rendering index: ", err.Error())
|
||||||
|
@ -63,7 +63,7 @@ func indexHandler(repo kiss.Repository) func(http.ResponseWriter, *http.Request,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func userHandler(repo kiss.Repository) func(http.ResponseWriter, *http.Request, httprouter.Params) {
|
func userHandler(repo owl.Repository) func(http.ResponseWriter, *http.Request, httprouter.Params) {
|
||||||
return func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
return func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
||||||
userName := ps.ByName("user")
|
userName := ps.ByName("user")
|
||||||
user, err := repo.GetUser(userName)
|
user, err := repo.GetUser(userName)
|
||||||
|
@ -73,7 +73,7 @@ func userHandler(repo kiss.Repository) func(http.ResponseWriter, *http.Request,
|
||||||
w.Write([]byte("User not found"))
|
w.Write([]byte("User not found"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
html, err := kiss.RenderIndexPage(user)
|
html, err := owl.RenderIndexPage(user)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
println("Error rendering index page: ", err.Error())
|
println("Error rendering index page: ", err.Error())
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
@ -85,7 +85,7 @@ func userHandler(repo kiss.Repository) func(http.ResponseWriter, *http.Request,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func postHandler(repo kiss.Repository) func(http.ResponseWriter, *http.Request, httprouter.Params) {
|
func postHandler(repo owl.Repository) func(http.ResponseWriter, *http.Request, httprouter.Params) {
|
||||||
return func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
return func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
||||||
userName := ps.ByName("user")
|
userName := ps.ByName("user")
|
||||||
postId := ps.ByName("post")
|
postId := ps.ByName("post")
|
||||||
|
@ -103,7 +103,7 @@ func postHandler(repo kiss.Repository) func(http.ResponseWriter, *http.Request,
|
||||||
w.Write([]byte("Post not found"))
|
w.Write([]byte("Post not found"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
html, err := kiss.RenderPost(post)
|
html, err := owl.RenderPost(post)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
println("Error rendering post: ", err.Error())
|
println("Error rendering post: ", err.Error())
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
@ -117,7 +117,7 @@ func postHandler(repo kiss.Repository) func(http.ResponseWriter, *http.Request,
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
println("KISS Web Server")
|
println("owl web server")
|
||||||
println("Parameters")
|
println("Parameters")
|
||||||
println("-repo <repo> - Specify the repository to use. Defaults to '.'")
|
println("-repo <repo> - Specify the repository to use. Defaults to '.'")
|
||||||
println("-port <port> - Specify the port to use, Default is '8080'")
|
println("-port <port> - Specify the port to use, Default is '8080'")
|
||||||
|
@ -138,7 +138,7 @@ func main() {
|
||||||
port = 8080
|
port = 8080
|
||||||
}
|
}
|
||||||
|
|
||||||
repo, err := kiss.OpenRepository(repoName)
|
repo, err := owl.OpenRepository(repoName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
println("Error opening repository: ", err.Error())
|
println("Error opening repository: ", err.Error())
|
||||||
os.Exit(1)
|
os.Exit(1)
|
|
@ -1,11 +1,11 @@
|
||||||
package static
|
package static
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"h4kor/kiss-social"
|
"h4kor/owl-blogs"
|
||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
func StaticHandler(repo kiss.Repository) http.Handler {
|
func StaticHandler(repo owl.Repository) http.Handler {
|
||||||
return http.StripPrefix(
|
return http.StripPrefix(
|
||||||
"/static/",
|
"/static/",
|
||||||
http.FileServer(http.Dir(repo.StaticDir())),
|
http.FileServer(http.Dir(repo.StaticDir())),
|
|
@ -1,8 +1,8 @@
|
||||||
package static_test
|
package static_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"h4kor/kiss-social"
|
"h4kor/owl-blogs"
|
||||||
"h4kor/kiss-social/cmd/kiss-web/static"
|
"h4kor/owl-blogs/cmd/owl-web/static"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
|
@ -26,8 +26,8 @@ func testRepoName() string {
|
||||||
return "/tmp/" + randomName()
|
return "/tmp/" + randomName()
|
||||||
}
|
}
|
||||||
|
|
||||||
func getTestRepo() kiss.Repository {
|
func getTestRepo() owl.Repository {
|
||||||
repo, _ := kiss.CreateRepository(testRepoName())
|
repo, _ := owl.CreateRepository(testRepoName())
|
||||||
return repo
|
return repo
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package kiss
|
package owl
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
<ul>
|
||||||
|
{{ range .UserLinks }}
|
||||||
|
<li><a href="{{.Href}}">{{.Text}}</a></li>
|
||||||
|
{{ end }}
|
||||||
|
</ul>
|
12
kiss_test.go
12
kiss_test.go
|
@ -1,7 +1,7 @@
|
||||||
package kiss_test
|
package owl_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"h4kor/kiss-social"
|
"h4kor/owl-blogs"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
@ -24,14 +24,14 @@ func randomUserName() string {
|
||||||
return randomName()
|
return randomName()
|
||||||
}
|
}
|
||||||
|
|
||||||
func getTestUser() kiss.User {
|
func getTestUser() owl.User {
|
||||||
repo, _ := kiss.CreateRepository(testRepoName())
|
repo, _ := owl.CreateRepository(testRepoName())
|
||||||
user, _ := repo.CreateUser(randomUserName())
|
user, _ := repo.CreateUser(randomUserName())
|
||||||
return user
|
return user
|
||||||
}
|
}
|
||||||
|
|
||||||
func getTestRepo() kiss.Repository {
|
func getTestRepo() owl.Repository {
|
||||||
repo, _ := kiss.CreateRepository(testRepoName())
|
repo, _ := owl.CreateRepository(testRepoName())
|
||||||
return repo
|
return repo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package kiss_test
|
package owl_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"path"
|
"path"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package kiss
|
package owl
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package kiss_test
|
package owl_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"h4kor/kiss-social"
|
"h4kor/owl-blogs"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -11,7 +11,7 @@ import (
|
||||||
func TestCanRenderPost(t *testing.T) {
|
func TestCanRenderPost(t *testing.T) {
|
||||||
user := getTestUser()
|
user := getTestUser()
|
||||||
post, _ := user.CreateNewPost("testpost")
|
post, _ := user.CreateNewPost("testpost")
|
||||||
result, err := kiss.RenderPost(post)
|
result, err := owl.RenderPost(post)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error("Error rendering post: " + err.Error())
|
t.Error("Error rendering post: " + err.Error())
|
||||||
|
@ -27,7 +27,7 @@ func TestCanRenderPost(t *testing.T) {
|
||||||
func TestRendererUsesBaseTemplate(t *testing.T) {
|
func TestRendererUsesBaseTemplate(t *testing.T) {
|
||||||
user := getTestUser()
|
user := getTestUser()
|
||||||
post, _ := user.CreateNewPost("testpost")
|
post, _ := user.CreateNewPost("testpost")
|
||||||
result, err := kiss.RenderPost(post)
|
result, err := owl.RenderPost(post)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error("Error rendering post: " + err.Error())
|
t.Error("Error rendering post: " + err.Error())
|
||||||
|
@ -43,7 +43,7 @@ func TestCanRenderIndexPage(t *testing.T) {
|
||||||
user := getTestUser()
|
user := getTestUser()
|
||||||
user.CreateNewPost("testpost1")
|
user.CreateNewPost("testpost1")
|
||||||
user.CreateNewPost("testpost2")
|
user.CreateNewPost("testpost2")
|
||||||
result, _ := kiss.RenderIndexPage(user)
|
result, _ := owl.RenderIndexPage(user)
|
||||||
if !strings.Contains(result, "testpost1") {
|
if !strings.Contains(result, "testpost1") {
|
||||||
t.Error("Post title not rendered. Got: " + result)
|
t.Error("Post title not rendered. Got: " + result)
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ func TestRenderIndexPageWithBrokenBaseTemplate(t *testing.T) {
|
||||||
|
|
||||||
os.WriteFile(path.Join(user.Dir(), "meta/base.html"), []byte("{{content}}"), 0644)
|
os.WriteFile(path.Join(user.Dir(), "meta/base.html"), []byte("{{content}}"), 0644)
|
||||||
|
|
||||||
_, err := kiss.RenderIndexPage(user)
|
_, err := owl.RenderIndexPage(user)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Error("Expected error rendering index page, got nil")
|
t.Error("Expected error rendering index page, got nil")
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ func TestRenderUserList(t *testing.T) {
|
||||||
repo.CreateUser("user1")
|
repo.CreateUser("user1")
|
||||||
repo.CreateUser("user2")
|
repo.CreateUser("user2")
|
||||||
|
|
||||||
result, err := kiss.RenderUserList(repo)
|
result, err := owl.RenderUserList(repo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error("Error rendering user list: " + err.Error())
|
t.Error("Error rendering user list: " + err.Error())
|
||||||
}
|
}
|
||||||
|
@ -85,14 +85,14 @@ func TestRenderUserList(t *testing.T) {
|
||||||
|
|
||||||
func TestRendersHeaderTitle(t *testing.T) {
|
func TestRendersHeaderTitle(t *testing.T) {
|
||||||
user := getTestUser()
|
user := getTestUser()
|
||||||
user.SetConfig(kiss.UserConfig{
|
user.SetConfig(owl.UserConfig{
|
||||||
Title: "Test Title",
|
Title: "Test Title",
|
||||||
SubTitle: "Test SubTitle",
|
SubTitle: "Test SubTitle",
|
||||||
HeaderColor: "#ff1337",
|
HeaderColor: "#ff1337",
|
||||||
})
|
})
|
||||||
post, _ := user.CreateNewPost("testpost")
|
post, _ := user.CreateNewPost("testpost")
|
||||||
|
|
||||||
result, _ := kiss.RenderPost(post)
|
result, _ := owl.RenderPost(post)
|
||||||
if !strings.Contains(result, "Test Title") {
|
if !strings.Contains(result, "Test Title") {
|
||||||
t.Error("Header title not rendered. Got: " + result)
|
t.Error("Header title not rendered. Got: " + result)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package kiss
|
package owl
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"embed"
|
"embed"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package kiss_test
|
package owl_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"h4kor/kiss-social"
|
"h4kor/owl-blogs"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -9,7 +9,7 @@ import (
|
||||||
|
|
||||||
func TestCanCreateRepository(t *testing.T) {
|
func TestCanCreateRepository(t *testing.T) {
|
||||||
repoName := testRepoName()
|
repoName := testRepoName()
|
||||||
_, err := kiss.CreateRepository(repoName)
|
_, err := owl.CreateRepository(repoName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error("Error creating repository: ", err.Error())
|
t.Error("Error creating repository: ", err.Error())
|
||||||
}
|
}
|
||||||
|
@ -18,8 +18,8 @@ func TestCanCreateRepository(t *testing.T) {
|
||||||
|
|
||||||
func TestCannotCreateExistingRepository(t *testing.T) {
|
func TestCannotCreateExistingRepository(t *testing.T) {
|
||||||
repoName := testRepoName()
|
repoName := testRepoName()
|
||||||
kiss.CreateRepository(repoName)
|
owl.CreateRepository(repoName)
|
||||||
_, err := kiss.CreateRepository(repoName)
|
_, err := owl.CreateRepository(repoName)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Error("No error returned when creating existing repository")
|
t.Error("No error returned when creating existing repository")
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ func TestCannotCreateExistingRepository(t *testing.T) {
|
||||||
|
|
||||||
func TestCanCreateANewUser(t *testing.T) {
|
func TestCanCreateANewUser(t *testing.T) {
|
||||||
// Create a new user
|
// Create a new user
|
||||||
repo, _ := kiss.CreateRepository(testRepoName())
|
repo, _ := owl.CreateRepository(testRepoName())
|
||||||
user, _ := repo.CreateUser(randomUserName())
|
user, _ := repo.CreateUser(randomUserName())
|
||||||
if _, err := os.Stat(path.Join(user.Dir(), "")); err != nil {
|
if _, err := os.Stat(path.Join(user.Dir(), "")); err != nil {
|
||||||
t.Error("User directory not created")
|
t.Error("User directory not created")
|
||||||
|
@ -36,7 +36,7 @@ func TestCanCreateANewUser(t *testing.T) {
|
||||||
|
|
||||||
func TestCannotRecreateExisitingUser(t *testing.T) {
|
func TestCannotRecreateExisitingUser(t *testing.T) {
|
||||||
// Create a new user
|
// Create a new user
|
||||||
repo, _ := kiss.CreateRepository(testRepoName())
|
repo, _ := owl.CreateRepository(testRepoName())
|
||||||
userName := randomUserName()
|
userName := randomUserName()
|
||||||
repo.CreateUser(userName)
|
repo.CreateUser(userName)
|
||||||
_, err := repo.CreateUser(userName)
|
_, err := repo.CreateUser(userName)
|
||||||
|
@ -47,7 +47,7 @@ func TestCannotRecreateExisitingUser(t *testing.T) {
|
||||||
|
|
||||||
func TestCreateUserAddsVersionFile(t *testing.T) {
|
func TestCreateUserAddsVersionFile(t *testing.T) {
|
||||||
// Create a new user
|
// Create a new user
|
||||||
repo, _ := kiss.CreateRepository(testRepoName())
|
repo, _ := owl.CreateRepository(testRepoName())
|
||||||
user, _ := repo.CreateUser(randomUserName())
|
user, _ := repo.CreateUser(randomUserName())
|
||||||
if _, err := os.Stat(path.Join(user.Dir(), "/meta/VERSION")); err != nil {
|
if _, err := os.Stat(path.Join(user.Dir(), "/meta/VERSION")); err != nil {
|
||||||
t.Error("Version file not created")
|
t.Error("Version file not created")
|
||||||
|
@ -56,7 +56,7 @@ func TestCreateUserAddsVersionFile(t *testing.T) {
|
||||||
|
|
||||||
func TestCreateUserAddsBaseHtmlFile(t *testing.T) {
|
func TestCreateUserAddsBaseHtmlFile(t *testing.T) {
|
||||||
// Create a new user
|
// Create a new user
|
||||||
repo, _ := kiss.CreateRepository(testRepoName())
|
repo, _ := owl.CreateRepository(testRepoName())
|
||||||
user, _ := repo.CreateUser(randomUserName())
|
user, _ := repo.CreateUser(randomUserName())
|
||||||
if _, err := os.Stat(path.Join(user.Dir(), "/meta/base.html")); err != nil {
|
if _, err := os.Stat(path.Join(user.Dir(), "/meta/base.html")); err != nil {
|
||||||
t.Error("Base html file not created")
|
t.Error("Base html file not created")
|
||||||
|
@ -65,7 +65,7 @@ func TestCreateUserAddsBaseHtmlFile(t *testing.T) {
|
||||||
|
|
||||||
func TestCreateUserAddConfigYml(t *testing.T) {
|
func TestCreateUserAddConfigYml(t *testing.T) {
|
||||||
// Create a new user
|
// Create a new user
|
||||||
repo, _ := kiss.CreateRepository(testRepoName())
|
repo, _ := owl.CreateRepository(testRepoName())
|
||||||
user, _ := repo.CreateUser(randomUserName())
|
user, _ := repo.CreateUser(randomUserName())
|
||||||
if _, err := os.Stat(path.Join(user.Dir(), "/meta/config.yml")); err != nil {
|
if _, err := os.Stat(path.Join(user.Dir(), "/meta/config.yml")); err != nil {
|
||||||
t.Error("Config file not created")
|
t.Error("Config file not created")
|
||||||
|
@ -74,7 +74,7 @@ func TestCreateUserAddConfigYml(t *testing.T) {
|
||||||
|
|
||||||
func TestCreateUserAddsPublicFolder(t *testing.T) {
|
func TestCreateUserAddsPublicFolder(t *testing.T) {
|
||||||
// Create a new user
|
// Create a new user
|
||||||
repo, _ := kiss.CreateRepository(testRepoName())
|
repo, _ := owl.CreateRepository(testRepoName())
|
||||||
user, _ := repo.CreateUser(randomUserName())
|
user, _ := repo.CreateUser(randomUserName())
|
||||||
if _, err := os.Stat(path.Join(user.Dir(), "/public")); err != nil {
|
if _, err := os.Stat(path.Join(user.Dir(), "/public")); err != nil {
|
||||||
t.Error("Public folder not created")
|
t.Error("Public folder not created")
|
||||||
|
@ -83,7 +83,7 @@ func TestCreateUserAddsPublicFolder(t *testing.T) {
|
||||||
|
|
||||||
func TestCanListRepoUsers(t *testing.T) {
|
func TestCanListRepoUsers(t *testing.T) {
|
||||||
// Create a new user
|
// Create a new user
|
||||||
repo, _ := kiss.CreateRepository(testRepoName())
|
repo, _ := owl.CreateRepository(testRepoName())
|
||||||
user1, _ := repo.CreateUser(randomUserName())
|
user1, _ := repo.CreateUser(randomUserName())
|
||||||
user2, _ := repo.CreateUser(randomUserName())
|
user2, _ := repo.CreateUser(randomUserName())
|
||||||
// Create a new post
|
// Create a new post
|
||||||
|
@ -101,9 +101,9 @@ func TestCanListRepoUsers(t *testing.T) {
|
||||||
func TestCanOpenRepository(t *testing.T) {
|
func TestCanOpenRepository(t *testing.T) {
|
||||||
// Create a new user
|
// Create a new user
|
||||||
repoName := testRepoName()
|
repoName := testRepoName()
|
||||||
repo, _ := kiss.CreateRepository(repoName)
|
repo, _ := owl.CreateRepository(repoName)
|
||||||
// Open the repository
|
// Open the repository
|
||||||
repo2, err := kiss.OpenRepository(repoName)
|
repo2, err := owl.OpenRepository(repoName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error("Error opening repository: ", err.Error())
|
t.Error("Error opening repository: ", err.Error())
|
||||||
}
|
}
|
||||||
|
@ -113,7 +113,7 @@ func TestCanOpenRepository(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCannotOpenNonExisitingRepo(t *testing.T) {
|
func TestCannotOpenNonExisitingRepo(t *testing.T) {
|
||||||
_, err := kiss.OpenRepository(testRepoName())
|
_, err := owl.OpenRepository(testRepoName())
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Error("No error returned when opening non-existing repository")
|
t.Error("No error returned when opening non-existing repository")
|
||||||
}
|
}
|
||||||
|
@ -121,7 +121,7 @@ func TestCannotOpenNonExisitingRepo(t *testing.T) {
|
||||||
|
|
||||||
func TestGetUser(t *testing.T) {
|
func TestGetUser(t *testing.T) {
|
||||||
// Create a new user
|
// Create a new user
|
||||||
repo, _ := kiss.CreateRepository(testRepoName())
|
repo, _ := owl.CreateRepository(testRepoName())
|
||||||
user, _ := repo.CreateUser(randomUserName())
|
user, _ := repo.CreateUser(randomUserName())
|
||||||
// Get the user
|
// Get the user
|
||||||
user2, err := repo.GetUser(user.Name())
|
user2, err := repo.GetUser(user.Name())
|
||||||
|
@ -135,7 +135,7 @@ func TestGetUser(t *testing.T) {
|
||||||
|
|
||||||
func TestCannotGetNonexistingUser(t *testing.T) {
|
func TestCannotGetNonexistingUser(t *testing.T) {
|
||||||
// Create a new user
|
// Create a new user
|
||||||
repo, _ := kiss.CreateRepository(testRepoName())
|
repo, _ := owl.CreateRepository(testRepoName())
|
||||||
_, err := repo.GetUser(randomUserName())
|
_, err := repo.GetUser(randomUserName())
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Error("No error returned when getting non-existing user")
|
t.Error("No error returned when getting non-existing user")
|
||||||
|
@ -144,7 +144,7 @@ func TestCannotGetNonexistingUser(t *testing.T) {
|
||||||
|
|
||||||
func TestGetStaticDirOfRepo(t *testing.T) {
|
func TestGetStaticDirOfRepo(t *testing.T) {
|
||||||
// Create a new user
|
// Create a new user
|
||||||
repo, _ := kiss.CreateRepository(testRepoName())
|
repo, _ := owl.CreateRepository(testRepoName())
|
||||||
// Get the user
|
// Get the user
|
||||||
staticDir := repo.StaticDir()
|
staticDir := repo.StaticDir()
|
||||||
if staticDir == "" {
|
if staticDir == "" {
|
||||||
|
@ -154,7 +154,7 @@ func TestGetStaticDirOfRepo(t *testing.T) {
|
||||||
|
|
||||||
func TestNewRepoGetsStaticFiles(t *testing.T) {
|
func TestNewRepoGetsStaticFiles(t *testing.T) {
|
||||||
// Create a new user
|
// Create a new user
|
||||||
repo, _ := kiss.CreateRepository(testRepoName())
|
repo, _ := owl.CreateRepository(testRepoName())
|
||||||
if _, err := os.Stat(repo.StaticDir()); err != nil {
|
if _, err := os.Stat(repo.StaticDir()); err != nil {
|
||||||
t.Error("Static directory not found")
|
t.Error("Static directory not found")
|
||||||
}
|
}
|
||||||
|
@ -169,7 +169,7 @@ func TestNewRepoGetsStaticFiles(t *testing.T) {
|
||||||
|
|
||||||
func TestNewRepoGetsBaseHtml(t *testing.T) {
|
func TestNewRepoGetsBaseHtml(t *testing.T) {
|
||||||
// Create a new user
|
// Create a new user
|
||||||
repo, _ := kiss.CreateRepository(testRepoName())
|
repo, _ := owl.CreateRepository(testRepoName())
|
||||||
if _, err := os.Stat(path.Join(repo.Dir(), "/base.html")); err != nil {
|
if _, err := os.Stat(path.Join(repo.Dir(), "/base.html")); err != nil {
|
||||||
t.Error("Base html file not found")
|
t.Error("Base html file not found")
|
||||||
}
|
}
|
||||||
|
@ -177,7 +177,7 @@ func TestNewRepoGetsBaseHtml(t *testing.T) {
|
||||||
|
|
||||||
func TestCanGetRepoTemplate(t *testing.T) {
|
func TestCanGetRepoTemplate(t *testing.T) {
|
||||||
// Create a new user
|
// Create a new user
|
||||||
repo, _ := kiss.CreateRepository(testRepoName())
|
repo, _ := owl.CreateRepository(testRepoName())
|
||||||
// Get the user
|
// Get the user
|
||||||
template, err := repo.Template()
|
template, err := repo.Template()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
14
user_test.go
14
user_test.go
|
@ -1,8 +1,8 @@
|
||||||
package kiss_test
|
package owl_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"h4kor/kiss-social"
|
"h4kor/owl-blogs"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
|
@ -11,7 +11,7 @@ import (
|
||||||
|
|
||||||
func TestCreateNewPostCreatesEntryInPublic(t *testing.T) {
|
func TestCreateNewPostCreatesEntryInPublic(t *testing.T) {
|
||||||
// Create a new user
|
// Create a new user
|
||||||
repo, _ := kiss.CreateRepository(testRepoName())
|
repo, _ := owl.CreateRepository(testRepoName())
|
||||||
user, _ := repo.CreateUser(randomUserName())
|
user, _ := repo.CreateUser(randomUserName())
|
||||||
// Create a new post
|
// Create a new post
|
||||||
user.CreateNewPost("testpost")
|
user.CreateNewPost("testpost")
|
||||||
|
@ -26,7 +26,7 @@ func TestCreateNewPostCreatesEntryInPublic(t *testing.T) {
|
||||||
|
|
||||||
func TestCreateNewPostCreatesMediaDir(t *testing.T) {
|
func TestCreateNewPostCreatesMediaDir(t *testing.T) {
|
||||||
// Create a new user
|
// Create a new user
|
||||||
repo, _ := kiss.CreateRepository(testRepoName())
|
repo, _ := owl.CreateRepository(testRepoName())
|
||||||
user, _ := repo.CreateUser(randomUserName())
|
user, _ := repo.CreateUser(randomUserName())
|
||||||
// Create a new post
|
// Create a new post
|
||||||
post, _ := user.CreateNewPost("testpost")
|
post, _ := user.CreateNewPost("testpost")
|
||||||
|
@ -37,7 +37,7 @@ func TestCreateNewPostCreatesMediaDir(t *testing.T) {
|
||||||
|
|
||||||
func TestCreateNewPostMultipleCalls(t *testing.T) {
|
func TestCreateNewPostMultipleCalls(t *testing.T) {
|
||||||
// Create a new user
|
// Create a new user
|
||||||
repo, _ := kiss.CreateRepository(testRepoName())
|
repo, _ := owl.CreateRepository(testRepoName())
|
||||||
user, _ := repo.CreateUser(randomUserName())
|
user, _ := repo.CreateUser(randomUserName())
|
||||||
// Create a new post
|
// Create a new post
|
||||||
user.CreateNewPost("testpost")
|
user.CreateNewPost("testpost")
|
||||||
|
@ -54,7 +54,7 @@ func TestCreateNewPostMultipleCalls(t *testing.T) {
|
||||||
|
|
||||||
func TestCanListUserPosts(t *testing.T) {
|
func TestCanListUserPosts(t *testing.T) {
|
||||||
// Create a new user
|
// Create a new user
|
||||||
repo, _ := kiss.CreateRepository(testRepoName())
|
repo, _ := owl.CreateRepository(testRepoName())
|
||||||
user, _ := repo.CreateUser(randomUserName())
|
user, _ := repo.CreateUser(randomUserName())
|
||||||
// Create a new post
|
// Create a new post
|
||||||
user.CreateNewPost("testpost")
|
user.CreateNewPost("testpost")
|
||||||
|
@ -71,7 +71,7 @@ func TestCanListUserPosts(t *testing.T) {
|
||||||
|
|
||||||
func TestCanListUserPostsWithSubdirectories(t *testing.T) {
|
func TestCanListUserPostsWithSubdirectories(t *testing.T) {
|
||||||
// Create a new user
|
// Create a new user
|
||||||
repo, _ := kiss.CreateRepository(testRepoName())
|
repo, _ := owl.CreateRepository(testRepoName())
|
||||||
user, _ := repo.CreateUser(randomUserName())
|
user, _ := repo.CreateUser(randomUserName())
|
||||||
// Create a new post
|
// Create a new post
|
||||||
user.CreateNewPost("testpost")
|
user.CreateNewPost("testpost")
|
||||||
|
|
Loading…
Reference in New Issue