Fixed log errors and improved tests
This commit is contained in:
parent
28f58bcadc
commit
745b6f18e3
@ -22,7 +22,7 @@ const (
|
|||||||
|
|
||||||
var avatarSources []AvatarSource
|
var avatarSources []AvatarSource
|
||||||
var avatarOutputs []AvatarOutput
|
var avatarOutputs []AvatarOutput
|
||||||
var avatarLog = log.NewLog()
|
var avatarLog = log.New()
|
||||||
|
|
||||||
// Main
|
// Main
|
||||||
func main() {
|
func main() {
|
||||||
|
@ -13,10 +13,10 @@ import (
|
|||||||
|
|
||||||
// Log middleware logs every request into logs/request.log and errors into logs/error.log.
|
// Log middleware logs every request into logs/request.log and errors into logs/error.log.
|
||||||
func Log() aero.Middleware {
|
func Log() aero.Middleware {
|
||||||
request := log.NewLog()
|
request := log.New()
|
||||||
request.AddOutput(log.File("logs/request.log"))
|
request.AddOutput(log.File("logs/request.log"))
|
||||||
|
|
||||||
err := log.NewLog()
|
err := log.New()
|
||||||
err.AddOutput(log.File("logs/error.log"))
|
err.AddOutput(log.File("logs/error.log"))
|
||||||
err.AddOutput(os.Stderr)
|
err.AddOutput(os.Stderr)
|
||||||
|
|
||||||
|
117
tests.go
117
tests.go
@ -1,113 +1,120 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
func init() {
|
var tests = map[string][]string{
|
||||||
// User
|
// User
|
||||||
app.Test("/user/:nick", []string{
|
"/user/:nick": []string{
|
||||||
"/+Akyoto",
|
"/+Akyoto",
|
||||||
})
|
},
|
||||||
|
|
||||||
app.Test("/user/:nick/threads", []string{
|
"/user/:nick/threads": []string{
|
||||||
"/+Akyoto/threads",
|
"/+Akyoto/threads",
|
||||||
})
|
},
|
||||||
|
|
||||||
app.Test("/user/:nick/animelist", []string{
|
"/user/:nick/animelist": []string{
|
||||||
"/+Akyoto/animelist",
|
"/+Akyoto/animelist",
|
||||||
})
|
},
|
||||||
|
|
||||||
app.Test("/user/:nick/animelist/:id", []string{
|
"/user/:nick/animelist/:id": []string{
|
||||||
"/+Akyoto/animelist/7929",
|
"/+Akyoto/animelist/7929",
|
||||||
})
|
},
|
||||||
|
|
||||||
// Pages
|
// Pages
|
||||||
app.Test("/anime/:id", []string{
|
"/anime/:id": []string{
|
||||||
"/anime/1",
|
"/anime/1",
|
||||||
})
|
},
|
||||||
|
|
||||||
app.Test("/threads/:id", []string{
|
"/threads/:id": []string{
|
||||||
"/threads/HJgS7c2K",
|
"/threads/HJgS7c2K",
|
||||||
})
|
},
|
||||||
|
|
||||||
app.Test("/posts/:id", []string{
|
"/posts/:id": []string{
|
||||||
"/posts/B1RzshnK",
|
"/posts/B1RzshnK",
|
||||||
})
|
},
|
||||||
|
|
||||||
app.Test("/forum/:tag", []string{
|
"/forum/:tag": []string{
|
||||||
"/forum/general",
|
"/forum/general",
|
||||||
})
|
},
|
||||||
|
|
||||||
app.Test("/search/:term", []string{
|
"/search/:term": []string{
|
||||||
"/search/Dragon Ball",
|
"/search/Dragon Ball",
|
||||||
})
|
},
|
||||||
|
|
||||||
// API
|
// API
|
||||||
app.Test("/api/anime/:id", []string{
|
"/api/anime/:id": []string{
|
||||||
"/api/anime/1",
|
"/api/anime/1",
|
||||||
})
|
},
|
||||||
|
|
||||||
app.Test("/api/thread/:id", []string{
|
"/api/thread/:id": []string{
|
||||||
"/api/thread/HJgS7c2K",
|
"/api/thread/HJgS7c2K",
|
||||||
})
|
},
|
||||||
|
|
||||||
app.Test("/api/post/:id", []string{
|
"/api/post/:id": []string{
|
||||||
"/api/post/B1RzshnK",
|
"/api/post/B1RzshnK",
|
||||||
})
|
},
|
||||||
|
|
||||||
app.Test("/api/animelist/:id", []string{
|
"/api/animelist/:id": []string{
|
||||||
"/api/animelist/4J6qpK1ve",
|
"/api/animelist/4J6qpK1ve",
|
||||||
})
|
},
|
||||||
|
|
||||||
app.Test("/api/settings/:id", []string{
|
"/api/settings/:id": []string{
|
||||||
"/api/settings/4J6qpK1ve",
|
"/api/settings/4J6qpK1ve",
|
||||||
})
|
},
|
||||||
|
|
||||||
app.Test("/api/user/:id", []string{
|
"/api/user/:id": []string{
|
||||||
"/api/user/4J6qpK1ve",
|
"/api/user/4J6qpK1ve",
|
||||||
})
|
},
|
||||||
|
|
||||||
app.Test("/api/emailtouser/:id", []string{
|
"/api/emailtouser/:id": []string{
|
||||||
"/api/emailtouser/e.urbach@gmail.com",
|
"/api/emailtouser/e.urbach@gmail.com",
|
||||||
})
|
},
|
||||||
|
|
||||||
app.Test("/api/googletouser/:id", []string{
|
"/api/googletouser/:id": []string{
|
||||||
"/api/googletouser/106530160120373282283",
|
"/api/googletouser/106530160120373282283",
|
||||||
})
|
},
|
||||||
|
|
||||||
app.Test("/api/nicktouser/:id", []string{
|
"/api/nicktouser/:id": []string{
|
||||||
"/api/nicktouser/Akyoto",
|
"/api/nicktouser/Akyoto",
|
||||||
})
|
},
|
||||||
|
|
||||||
app.Test("/api/searchindex/:id", []string{
|
"/api/searchindex/:id": []string{
|
||||||
"/api/searchindex/Anime",
|
"/api/searchindex/Anime",
|
||||||
})
|
},
|
||||||
|
|
||||||
// Images
|
// Images
|
||||||
app.Test("/images/avatars/large/:file", []string{
|
"/images/avatars/large/:file": []string{
|
||||||
"/images/avatars/large/4J6qpK1ve.webp",
|
"/images/avatars/large/4J6qpK1ve.webp",
|
||||||
})
|
},
|
||||||
|
|
||||||
app.Test("/images/avatars/small/:file", []string{
|
"/images/avatars/small/:file": []string{
|
||||||
"/images/avatars/small/4J6qpK1ve.webp",
|
"/images/avatars/small/4J6qpK1ve.webp",
|
||||||
})
|
},
|
||||||
|
|
||||||
app.Test("/images/brand/:file", []string{
|
"/images/brand/:file": []string{
|
||||||
"/images/brand/64.webp",
|
"/images/brand/64.webp",
|
||||||
})
|
},
|
||||||
|
|
||||||
app.Test("/images/login/:file", []string{
|
"/images/login/:file": []string{
|
||||||
"/images/login/google",
|
"/images/login/google",
|
||||||
})
|
},
|
||||||
|
|
||||||
app.Test("/images/cover/:file", []string{
|
"/images/cover/:file": []string{
|
||||||
"/images/cover/default",
|
"/images/cover/default",
|
||||||
})
|
},
|
||||||
|
|
||||||
app.Test("/images/elements/:file", []string{
|
"/images/elements/:file": []string{
|
||||||
"/images/elements/no-avatar.svg",
|
"/images/elements/no-avatar.svg",
|
||||||
})
|
},
|
||||||
|
|
||||||
// Disable
|
// Disable
|
||||||
app.Test("/auth/google", nil)
|
"/auth/google": nil,
|
||||||
app.Test("/auth/google/callback", nil)
|
"/auth/google/callback": nil,
|
||||||
app.Test("/user", nil)
|
"/user": nil,
|
||||||
app.Test("/settings", nil)
|
"/settings": nil,
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
// Specify test routes
|
||||||
|
for route, examples := range tests {
|
||||||
|
app.Test(route, examples)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user