58 lines
1.5 KiB
Go
58 lines
1.5 KiB
Go
package owl_test
|
|
|
|
import (
|
|
"path"
|
|
"testing"
|
|
)
|
|
|
|
func TestCanGetPostTitle(t *testing.T) {
|
|
user := getTestUser()
|
|
post, _ := user.CreateNewPost("testpost")
|
|
result := post.Title()
|
|
if result != "testpost" {
|
|
t.Error("Wrong Title. Got: " + result)
|
|
}
|
|
}
|
|
|
|
func TestMediaDir(t *testing.T) {
|
|
user := getTestUser()
|
|
post, _ := user.CreateNewPost("testpost")
|
|
result := post.MediaDir()
|
|
if result != path.Join(post.Dir(), "media") {
|
|
t.Error("Wrong MediaDir. Got: " + result)
|
|
}
|
|
}
|
|
|
|
func TestPostUrlPath(t *testing.T) {
|
|
user := getTestUser()
|
|
post, _ := user.CreateNewPost("testpost")
|
|
expected := "/user/" + user.Name() + "/posts/" + post.Id() + "/"
|
|
if !(post.UrlPath() == expected) {
|
|
t.Error("Wrong url path")
|
|
t.Error("Expected: " + expected)
|
|
t.Error(" Got: " + post.UrlPath())
|
|
}
|
|
}
|
|
|
|
func TestPostUrlMediaPath(t *testing.T) {
|
|
user := getTestUser()
|
|
post, _ := user.CreateNewPost("testpost")
|
|
expected := "/user/" + user.Name() + "/posts/" + post.Id() + "/media/data.png"
|
|
if !(post.UrlMediaPath("data.png") == expected) {
|
|
t.Error("Wrong url path")
|
|
t.Error("Expected: " + expected)
|
|
t.Error(" Got: " + post.UrlPath())
|
|
}
|
|
}
|
|
|
|
func TestPostUrlMediaPathWithSubDir(t *testing.T) {
|
|
user := getTestUser()
|
|
post, _ := user.CreateNewPost("testpost")
|
|
expected := "/user/" + user.Name() + "/posts/" + post.Id() + "/media/foo/data.png"
|
|
if !(post.UrlMediaPath("foo/data.png") == expected) {
|
|
t.Error("Wrong url path")
|
|
t.Error("Expected: " + expected)
|
|
t.Error(" Got: " + post.UrlPath())
|
|
}
|
|
}
|