2016-12-17 03:39:53 +00:00
|
|
|
package main
|
2017-04-12 10:10:36 +00:00
|
|
|
|
2017-06-10 07:58:15 +00:00
|
|
|
import (
|
2017-07-12 11:05:18 +00:00
|
|
|
//"os"
|
2017-06-10 07:58:15 +00:00
|
|
|
"log"
|
|
|
|
"bytes"
|
|
|
|
"strings"
|
|
|
|
"strconv"
|
|
|
|
//"math/rand"
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
"net/http"
|
|
|
|
"net/http/httptest"
|
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
|
|
|
"html/template"
|
2017-06-10 07:58:15 +00:00
|
|
|
"io/ioutil"
|
|
|
|
"database/sql"
|
2017-07-12 11:05:18 +00:00
|
|
|
//"runtime/pprof"
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-06-10 07:58:15 +00:00
|
|
|
//_ "github.com/go-sql-driver/mysql"
|
|
|
|
//"github.com/erikstmartin/go-testdb"
|
|
|
|
//"github.com/husobee/vestigo"
|
|
|
|
)
|
2017-01-17 07:55:46 +00:00
|
|
|
|
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
|
|
|
var db_test *sql.DB
|
|
|
|
var db_prod *sql.DB
|
|
|
|
var gloinited bool
|
2017-02-28 09:27:28 +00:00
|
|
|
|
2017-01-17 07:55:46 +00:00
|
|
|
func gloinit() {
|
2017-07-17 10:23:42 +00:00
|
|
|
dev.DebugMode = false
|
2017-06-10 07:58:15 +00:00
|
|
|
//nogrouplog = true
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-01-17 07:55:46 +00:00
|
|
|
// init_database is a little noisy for a benchmark
|
|
|
|
//discard := ioutil.Discard
|
|
|
|
//log.SetOutput(discard)
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-06-10 07:58:15 +00:00
|
|
|
startTime = time.Now()
|
2017-07-17 10:23:42 +00:00
|
|
|
//timeLocation = startTime.Location()
|
|
|
|
process_config()
|
2017-07-29 14:04:20 +00:00
|
|
|
|
2017-02-15 10:49:30 +00:00
|
|
|
init_themes()
|
2017-04-12 10:10:36 +00:00
|
|
|
err := init_database()
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-02-28 09:27:28 +00:00
|
|
|
db_prod = db
|
|
|
|
//db_test, err = sql.Open("testdb","")
|
|
|
|
//if err != nil {
|
|
|
|
// log.Fatal(err)
|
|
|
|
//}
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-02-15 10:49:30 +00:00
|
|
|
init_templates()
|
2017-02-28 09:27:28 +00:00
|
|
|
db_prod.SetMaxOpenConns(64)
|
2017-02-15 10:49:30 +00:00
|
|
|
err = init_errors()
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-07-17 10:23:42 +00:00
|
|
|
if config.CacheTopicUser == CACHE_STATIC {
|
2017-06-15 11:40:35 +00:00
|
|
|
users = NewMemoryUserStore(user_cache_capacity)
|
|
|
|
topics = NewMemoryTopicStore(topic_cache_capacity)
|
2017-02-15 10:49:30 +00:00
|
|
|
} else {
|
|
|
|
users = NewSqlUserStore()
|
|
|
|
topics = NewSqlTopicStore()
|
|
|
|
}
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-02-15 10:49:30 +00:00
|
|
|
init_static_files()
|
2017-01-17 07:55:46 +00:00
|
|
|
external_sites["YT"] = "https://www.youtube.com/"
|
|
|
|
//log.SetOutput(os.Stdout)
|
2017-07-12 11:05:18 +00:00
|
|
|
|
|
|
|
router = NewGenRouter(http.FileServer(http.Dir("./uploads")))
|
2017-01-17 07:55:46 +00:00
|
|
|
gloinited = true
|
|
|
|
}
|
2016-12-17 03:39:53 +00:00
|
|
|
|
2017-02-15 10:49:30 +00:00
|
|
|
func init() {
|
|
|
|
gloinit()
|
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkTopicTemplateSerial(b *testing.B) {
|
2016-12-23 12:35:22 +00:00
|
|
|
b.ReportAllocs()
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-07-12 11:05:18 +00:00
|
|
|
user := User{0,"bob","Bob","bob@localhost",0,false,false,false,false,false,false,GuestPerms,make(map[string]bool),"",false,"","","","","",0,0,"127.0.0.1"}
|
|
|
|
admin := User{1,"admin-alice","Admin Alice","admin@localhost",0,true,true,true,true,true,false,AllPerms,make(map[string]bool),"",false,"","","","","",-1,58,"127.0.0.1"}
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-02-15 10:49:30 +00:00
|
|
|
topic := TopicUser{Title: "Lol",Content: "Hey everyone!",CreatedBy: 1,CreatedAt: "0000-00-00 00:00:00",ParentID: 1,CreatedByName:"Admin",Css: no_css_tmpl,Tag: "Admin", Level: 58, IpAddress: "127.0.0.1"}
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2016-12-23 12:35:22 +00:00
|
|
|
var replyList []Reply
|
2017-07-17 10:23:42 +00:00
|
|
|
replyList = append(replyList, Reply{0,0,"Hey everyone!","Hey everyone!",0,"jerry","Jerry",config.DefaultGroup,"",0,0,"",no_css_tmpl,0,"","","","",0,"127.0.0.1",false,1,"",""})
|
|
|
|
replyList = append(replyList, Reply{0,0,"Hey everyone!","Hey everyone!",0,"jerry2","Jerry2",config.DefaultGroup,"",0,0,"",no_css_tmpl,0,"","","","",0,"127.0.0.1",false,1,"",""})
|
|
|
|
replyList = append(replyList, Reply{0,0,"Hey everyone!","Hey everyone!",0,"jerry3","Jerry3",config.DefaultGroup,"",0,0,"",no_css_tmpl,0,"","","","",0,"127.0.0.1",false,1,"",""})
|
|
|
|
replyList = append(replyList, Reply{0,0,"Hey everyone!","Hey everyone!",0,"jerry4","Jerry4",config.DefaultGroup,"",0,0,"",no_css_tmpl,0,"","","","",0,"127.0.0.1",false,1,"",""})
|
|
|
|
replyList = append(replyList, Reply{0,0,"Hey everyone!","Hey everyone!",0,"jerry5","Jerry5",config.DefaultGroup,"",0,0,"",no_css_tmpl,0,"","","","",0,"127.0.0.1",false,1,"",""})
|
|
|
|
replyList = append(replyList, Reply{0,0,"Hey everyone!","Hey everyone!",0,"jerry6","Jerry6",config.DefaultGroup,"",0,0,"",no_css_tmpl,0,"","","","",0,"127.0.0.1",false,1,"",""})
|
|
|
|
replyList = append(replyList, Reply{0,0,"Hey everyone!","Hey everyone!",0,"jerry7","Jerry7",config.DefaultGroup,"",0,0,"",no_css_tmpl,0,"","","","",0,"127.0.0.1",false,1,"",""})
|
|
|
|
replyList = append(replyList, Reply{0,0,"Hey everyone!","Hey everyone!",0,"jerry8","Jerry8",config.DefaultGroup,"",0,0,"",no_css_tmpl,0,"","","","",0,"127.0.0.1",false,1,"",""})
|
|
|
|
replyList = append(replyList, Reply{0,0,"Hey everyone!","Hey everyone!",0,"jerry9","Jerry9",config.DefaultGroup,"",0,0,"",no_css_tmpl,0,"","","","",0,"127.0.0.1",false,1,"",""})
|
|
|
|
replyList = append(replyList, Reply{0,0,"Hey everyone!","Hey everyone!",0,"jerry10","Jerry10",config.DefaultGroup,"",0,0,"",no_css_tmpl,0,"","","","",0,"127.0.0.1",false,1,"",""})
|
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
|
|
|
|
|
|
|
headerVars := HeaderVars{
|
|
|
|
NoticeList:[]string{"test"},
|
|
|
|
Stylesheets:[]string{"panel"},
|
|
|
|
Scripts:[]string{"whatever"},
|
|
|
|
Widgets:PageWidgets{
|
|
|
|
LeftSidebar: template.HTML("lalala"),
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
tpage := TopicPage{"Topic Blah",user,headerVars,replyList,topic,1,1,extData}
|
|
|
|
tpage2 := TopicPage{"Topic Blah",admin,headerVars,replyList,topic,1,1,extData}
|
2016-12-23 12:35:22 +00:00
|
|
|
w := ioutil.Discard
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2016-12-23 12:35:22 +00:00
|
|
|
b.Run("compiled_useradmin", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
template_topic(tpage2,w)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("interpreted_useradmin", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
templates.ExecuteTemplate(w,"topic.html", tpage2)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("compiled_userguest", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
template_topic(tpage,w)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("interpreted_userguest", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
templates.ExecuteTemplate(w,"topic.html", tpage)
|
|
|
|
}
|
|
|
|
})
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-01-17 07:55:46 +00:00
|
|
|
w2 := httptest.NewRecorder()
|
|
|
|
b.Run("compiled_useradmin_recorder", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
w2.Body.Reset()
|
|
|
|
template_topic(tpage2,w2)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("interpreted_useradmin_recorder", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
w2.Body.Reset()
|
|
|
|
templates.ExecuteTemplate(w2,"topic.html", tpage2)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("compiled_userguest_recorder", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
w2.Body.Reset()
|
|
|
|
template_topic(tpage,w2)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("interpreted_userguest_recorder", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
w2.Body.Reset()
|
|
|
|
templates.ExecuteTemplate(w2,"topic.html", tpage)
|
|
|
|
}
|
|
|
|
})
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-01-17 07:55:46 +00:00
|
|
|
/*f, err := os.Create("topic_bench.prof")
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
pprof.StartCPUProfile(f)
|
|
|
|
defer pprof.StopCPUProfile()*/
|
2016-12-23 12:35:22 +00:00
|
|
|
}
|
|
|
|
|
2017-02-15 10:49:30 +00:00
|
|
|
func BenchmarkTopicsTemplateSerial(b *testing.B) {
|
2016-12-23 12:35:22 +00:00
|
|
|
b.ReportAllocs()
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-07-12 11:05:18 +00:00
|
|
|
user := User{0,"bob","Bob","bob@localhost",0,false,false,false,false,false,false,GuestPerms,make(map[string]bool),"",false,"","","","","",0,0,"127.0.0.1"}
|
|
|
|
admin := User{1,"admin-alice","Admin Alice","admin@localhost",0,true,true,true,true,true,false,AllPerms,make(map[string]bool),"",false,"","","","","",-1,58,"127.0.0.1"}
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-02-15 10:49:30 +00:00
|
|
|
var topicList []TopicsRow
|
2017-07-29 14:04:20 +00:00
|
|
|
topicList = append(topicList, TopicsRow{Title: "Hey everyone!",Content: "Hey everyone!",CreatedBy: 1,CreatedAt: "0000-00-00 00:00:00",ParentID: 1,UserLink:build_profile_url("admin-alice",1),CreatedByName:"Admin Alice",Css: no_css_tmpl,Tag: "Admin", Level: 58, IpAddress: "127.0.0.1"})
|
|
|
|
topicList = append(topicList, TopicsRow{Title: "Hey everyone!",Content: "Hey everyone!",CreatedBy: 1,CreatedAt: "0000-00-00 00:00:00",ParentID: 1,UserLink:build_profile_url("admin-alice",1),CreatedByName:"Admin Alice",Css: no_css_tmpl,Tag: "Admin", Level: 58, IpAddress: "127.0.0.1"})
|
|
|
|
topicList = append(topicList, TopicsRow{Title: "Hey everyone!",Content: "Hey everyone!",CreatedBy: 1,CreatedAt: "0000-00-00 00:00:00",ParentID: 1,UserLink:build_profile_url("admin-alice",1),CreatedByName:"Admin Alice",Css: no_css_tmpl,Tag: "Admin", Level: 58, IpAddress: "127.0.0.1"})
|
|
|
|
topicList = append(topicList, TopicsRow{Title: "Hey everyone!",Content: "Hey everyone!",CreatedBy: 1,CreatedAt: "0000-00-00 00:00:00",ParentID: 1,UserLink:build_profile_url("admin-alice",1),CreatedByName:"Admin Alice",Css: no_css_tmpl,Tag: "Admin", Level: 58, IpAddress: "127.0.0.1"})
|
|
|
|
topicList = append(topicList, TopicsRow{Title: "Hey everyone!",Content: "Hey everyone!",CreatedBy: 1,CreatedAt: "0000-00-00 00:00:00",ParentID: 1,UserLink:build_profile_url("admin-alice",1),CreatedByName:"Admin Alice",Css: no_css_tmpl,Tag: "Admin", Level: 58, IpAddress: "127.0.0.1"})
|
|
|
|
topicList = append(topicList, TopicsRow{Title: "Hey everyone!",Content: "Hey everyone!",CreatedBy: 1,CreatedAt: "0000-00-00 00:00:00",ParentID: 1,UserLink:build_profile_url("admin-alice",1),CreatedByName:"Admin Alice",Css: no_css_tmpl,Tag: "Admin", Level: 58, IpAddress: "127.0.0.1"})
|
|
|
|
topicList = append(topicList, TopicsRow{Title: "Hey everyone!",Content: "Hey everyone!",CreatedBy: 1,CreatedAt: "0000-00-00 00:00:00",ParentID: 1,UserLink:build_profile_url("admin-alice",1),CreatedByName:"Admin Alice",Css: no_css_tmpl,Tag: "Admin", Level: 58, IpAddress: "127.0.0.1"})
|
|
|
|
topicList = append(topicList, TopicsRow{Title: "Hey everyone!",Content: "Hey everyone!",CreatedBy: 1,CreatedAt: "0000-00-00 00:00:00",ParentID: 1,UserLink:build_profile_url("admin-alice",1),CreatedByName:"Admin Alice",Css: no_css_tmpl,Tag: "Admin", Level: 58, IpAddress: "127.0.0.1"})
|
|
|
|
topicList = append(topicList, TopicsRow{Title: "Hey everyone!",Content: "Hey everyone!",CreatedBy: 1,CreatedAt: "0000-00-00 00:00:00",ParentID: 1,UserLink:build_profile_url("admin-alice",1),CreatedByName:"Admin Alice",Css: no_css_tmpl,Tag: "Admin", Level: 58, IpAddress: "127.0.0.1"})
|
|
|
|
topicList = append(topicList, TopicsRow{Title: "Hey everyone!",Content: "Hey everyone!",CreatedBy: 1,CreatedAt: "0000-00-00 00:00:00",ParentID: 1,UserLink:build_profile_url("admin-alice",1),CreatedByName:"Admin Alice",Css: no_css_tmpl,Tag: "Admin", Level: 58, IpAddress: "127.0.0.1"})
|
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
|
|
|
|
|
|
|
headerVars := HeaderVars{
|
|
|
|
NoticeList:[]string{"test"},
|
|
|
|
Stylesheets:[]string{"panel"},
|
|
|
|
Scripts:[]string{"whatever"},
|
|
|
|
Widgets:PageWidgets{
|
|
|
|
LeftSidebar: template.HTML("lalala"),
|
|
|
|
},
|
|
|
|
}
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2016-12-17 03:39:53 +00:00
|
|
|
w := ioutil.Discard
|
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
|
|
|
tpage := TopicsPage{"Topic Blah",user,headerVars,topicList,extData}
|
|
|
|
tpage2 := TopicsPage{"Topic Blah",admin,headerVars,topicList,extData}
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2016-12-21 02:30:32 +00:00
|
|
|
b.Run("compiled_useradmin", func(b *testing.B) {
|
2016-12-17 03:39:53 +00:00
|
|
|
for i := 0; i < b.N; i++ {
|
2016-12-23 12:35:22 +00:00
|
|
|
template_topics(tpage2,w)
|
2016-12-17 03:39:53 +00:00
|
|
|
}
|
|
|
|
})
|
2017-01-17 07:55:46 +00:00
|
|
|
b.Run("interpreted_useradmin",func(b *testing.B) {
|
2016-12-17 03:39:53 +00:00
|
|
|
for i := 0; i < b.N; i++ {
|
2016-12-23 12:35:22 +00:00
|
|
|
templates.ExecuteTemplate(w,"topics.html", tpage2)
|
2016-12-17 03:39:53 +00:00
|
|
|
}
|
2016-12-23 12:35:22 +00:00
|
|
|
})
|
2017-01-17 07:55:46 +00:00
|
|
|
b.Run("compiled_userguest",func(b *testing.B) {
|
2016-12-17 03:39:53 +00:00
|
|
|
for i := 0; i < b.N; i++ {
|
2016-12-23 12:35:22 +00:00
|
|
|
template_topics(tpage,w)
|
2016-12-17 03:39:53 +00:00
|
|
|
}
|
|
|
|
})
|
2017-01-17 07:55:46 +00:00
|
|
|
b.Run("interpreted_userguest",func(b *testing.B) {
|
2016-12-21 02:30:32 +00:00
|
|
|
for i := 0; i < b.N; i++ {
|
2016-12-23 12:35:22 +00:00
|
|
|
templates.ExecuteTemplate(w,"topics.html", tpage)
|
2016-12-21 02:30:32 +00:00
|
|
|
}
|
2016-12-23 12:35:22 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2017-01-17 07:55:46 +00:00
|
|
|
func BenchmarkStaticRouteParallel(b *testing.B) {
|
|
|
|
b.ReportAllocs()
|
|
|
|
if !gloinited {
|
|
|
|
gloinit()
|
|
|
|
}
|
|
|
|
if !plugins_inited {
|
|
|
|
init_plugins()
|
|
|
|
}
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-01-17 07:55:46 +00:00
|
|
|
b.RunParallel(func(pb *testing.PB) {
|
|
|
|
static_w := httptest.NewRecorder()
|
|
|
|
static_req := httptest.NewRequest("get","/static/global.js",bytes.NewReader(nil))
|
|
|
|
static_handler := http.HandlerFunc(route_static)
|
|
|
|
for pb.Next() {
|
2017-02-15 10:49:30 +00:00
|
|
|
//static_w.Code = 200
|
2017-01-17 07:55:46 +00:00
|
|
|
static_w.Body.Reset()
|
|
|
|
static_handler.ServeHTTP(static_w,static_req)
|
2017-02-15 10:49:30 +00:00
|
|
|
//if static_w.Code != 200 {
|
|
|
|
// fmt.Println(static_w.Body)
|
|
|
|
// panic("HTTP Error!")
|
|
|
|
//}
|
2017-01-17 07:55:46 +00:00
|
|
|
}
|
|
|
|
})
|
2017-02-15 10:49:30 +00:00
|
|
|
}
|
2017-01-17 07:55:46 +00:00
|
|
|
|
2017-07-12 11:05:18 +00:00
|
|
|
// TO-DO: Make these routes compatible with the changes to the router
|
|
|
|
/*
|
2017-01-17 07:55:46 +00:00
|
|
|
func BenchmarkTopicAdminRouteParallel(b *testing.B) {
|
|
|
|
b.ReportAllocs()
|
|
|
|
if !gloinited {
|
|
|
|
gloinit()
|
|
|
|
}
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-01-17 07:55:46 +00:00
|
|
|
b.RunParallel(func(pb *testing.PB) {
|
2017-02-15 10:49:30 +00:00
|
|
|
admin, err := users.CascadeGet(1)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
if !admin.Is_Admin {
|
|
|
|
panic("UID1 is not an admin")
|
|
|
|
}
|
|
|
|
admin_uid_cookie := http.Cookie{Name:"uid",Value:"1",Path:"/",MaxAge: year}
|
|
|
|
admin_session_cookie := http.Cookie{Name:"session",Value: admin.Session,Path:"/",MaxAge: year}
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-01-17 07:55:46 +00:00
|
|
|
topic_w := httptest.NewRecorder()
|
|
|
|
topic_req := httptest.NewRequest("get","/topic/1",bytes.NewReader(nil))
|
|
|
|
topic_req_admin := topic_req
|
|
|
|
topic_req_admin.AddCookie(&admin_uid_cookie)
|
|
|
|
topic_req_admin.AddCookie(&admin_session_cookie)
|
|
|
|
topic_handler := http.HandlerFunc(route_topic_id)
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-01-17 07:55:46 +00:00
|
|
|
for pb.Next() {
|
2017-02-15 10:49:30 +00:00
|
|
|
topic_w.Body.Reset()
|
2017-01-17 07:55:46 +00:00
|
|
|
topic_handler.ServeHTTP(topic_w,topic_req_admin)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkTopicGuestRouteParallel(b *testing.B) {
|
|
|
|
b.ReportAllocs()
|
|
|
|
if !gloinited {
|
|
|
|
gloinit()
|
|
|
|
}
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-01-17 07:55:46 +00:00
|
|
|
b.RunParallel(func(pb *testing.PB) {
|
|
|
|
topic_w := httptest.NewRecorder()
|
|
|
|
topic_req := httptest.NewRequest("get","/topic/1",bytes.NewReader(nil))
|
|
|
|
topic_handler := http.HandlerFunc(route_topic_id)
|
|
|
|
for pb.Next() {
|
|
|
|
topic_w.Body.Reset()
|
|
|
|
topic_handler.ServeHTTP(topic_w,topic_req)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkForumsAdminRouteParallel(b *testing.B) {
|
|
|
|
b.ReportAllocs()
|
|
|
|
if !gloinited {
|
|
|
|
gloinit()
|
|
|
|
}
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-01-17 07:55:46 +00:00
|
|
|
b.RunParallel(func(pb *testing.PB) {
|
2017-02-15 10:49:30 +00:00
|
|
|
admin, err := users.CascadeGet(1)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
if !admin.Is_Admin {
|
|
|
|
panic("UID1 is not an admin")
|
|
|
|
}
|
|
|
|
admin_uid_cookie := http.Cookie{Name:"uid",Value:"1",Path:"/",MaxAge: year}
|
|
|
|
admin_session_cookie := http.Cookie{Name:"session",Value: admin.Session,Path:"/",MaxAge: year}
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-01-17 07:55:46 +00:00
|
|
|
forums_w := httptest.NewRecorder()
|
|
|
|
forums_req := httptest.NewRequest("get","/forums/",bytes.NewReader(nil))
|
|
|
|
forums_req_admin := forums_req
|
|
|
|
forums_req_admin.AddCookie(&admin_uid_cookie)
|
|
|
|
forums_req_admin.AddCookie(&admin_session_cookie)
|
|
|
|
forums_handler := http.HandlerFunc(route_forums)
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-01-17 07:55:46 +00:00
|
|
|
for pb.Next() {
|
|
|
|
forums_w.Body.Reset()
|
|
|
|
forums_handler.ServeHTTP(forums_w,forums_req_admin)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkForumsAdminRouteParallelProf(b *testing.B) {
|
|
|
|
b.ReportAllocs()
|
|
|
|
if !gloinited {
|
|
|
|
gloinit()
|
|
|
|
}
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-01-17 07:55:46 +00:00
|
|
|
b.RunParallel(func(pb *testing.PB) {
|
2017-02-15 10:49:30 +00:00
|
|
|
admin, err := users.CascadeGet(1)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
if !admin.Is_Admin {
|
|
|
|
panic("UID1 is not an admin")
|
|
|
|
}
|
|
|
|
admin_uid_cookie := http.Cookie{Name:"uid",Value:"1",Path:"/",MaxAge: year}
|
|
|
|
admin_session_cookie := http.Cookie{Name:"session",Value: admin.Session,Path: "/",MaxAge: year}
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-01-17 07:55:46 +00:00
|
|
|
forums_w := httptest.NewRecorder()
|
|
|
|
forums_req := httptest.NewRequest("get","/forums/",bytes.NewReader(nil))
|
|
|
|
forums_req_admin := forums_req
|
|
|
|
forums_req_admin.AddCookie(&admin_uid_cookie)
|
|
|
|
forums_req_admin.AddCookie(&admin_session_cookie)
|
|
|
|
forums_handler := http.HandlerFunc(route_forums)
|
|
|
|
f, err := os.Create("cpu_forums_admin_parallel.prof")
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
pprof.StartCPUProfile(f)
|
|
|
|
for pb.Next() {
|
|
|
|
forums_w.Body.Reset()
|
|
|
|
forums_handler.ServeHTTP(forums_w,forums_req_admin)
|
|
|
|
}
|
|
|
|
pprof.StopCPUProfile()
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkForumsGuestRouteParallel(b *testing.B) {
|
|
|
|
b.ReportAllocs()
|
|
|
|
if !gloinited {
|
|
|
|
gloinit()
|
|
|
|
}
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-01-17 07:55:46 +00:00
|
|
|
b.RunParallel(func(pb *testing.PB) {
|
|
|
|
forums_w := httptest.NewRecorder()
|
|
|
|
forums_req := httptest.NewRequest("get","/forums/",bytes.NewReader(nil))
|
|
|
|
forums_handler := http.HandlerFunc(route_forums)
|
|
|
|
for pb.Next() {
|
|
|
|
forums_w.Body.Reset()
|
|
|
|
forums_handler.ServeHTTP(forums_w,forums_req)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
2017-07-12 11:05:18 +00:00
|
|
|
*/
|
2017-01-17 07:55:46 +00:00
|
|
|
|
2017-06-10 07:58:15 +00:00
|
|
|
/*func BenchmarkRoutesSerial(b *testing.B) {
|
2016-12-23 12:35:22 +00:00
|
|
|
b.ReportAllocs()
|
2017-02-15 10:49:30 +00:00
|
|
|
admin, err := users.CascadeGet(1)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
if !admin.Is_Admin {
|
|
|
|
panic("UID1 is not an admin")
|
|
|
|
}
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-02-15 10:49:30 +00:00
|
|
|
admin_uid_cookie := http.Cookie{Name:"uid",Value:"1",Path:"/",MaxAge: year}
|
|
|
|
admin_session_cookie := http.Cookie{Name:"session",Value: admin.Session,Path: "/",MaxAge: year}
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-01-17 07:55:46 +00:00
|
|
|
if plugins_inited {
|
|
|
|
b.Log("Plugins have already been initialised, they can't be deinitialised so these tests will run with plugins on")
|
|
|
|
}
|
|
|
|
static_w := httptest.NewRecorder()
|
|
|
|
static_req := httptest.NewRequest("get","/static/global.js",bytes.NewReader(nil))
|
|
|
|
static_handler := http.HandlerFunc(route_static)
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2016-12-23 12:35:22 +00:00
|
|
|
topic_w := httptest.NewRecorder()
|
|
|
|
topic_req := httptest.NewRequest("get","/topic/1",bytes.NewReader(nil))
|
|
|
|
topic_req_admin := topic_req
|
|
|
|
topic_req_admin.AddCookie(&admin_uid_cookie)
|
|
|
|
topic_req_admin.AddCookie(&admin_session_cookie)
|
|
|
|
topic_handler := http.HandlerFunc(route_topic_id)
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2016-12-23 12:35:22 +00:00
|
|
|
topics_w := httptest.NewRecorder()
|
|
|
|
topics_req := httptest.NewRequest("get","/topics/",bytes.NewReader(nil))
|
|
|
|
topics_req_admin := topics_req
|
|
|
|
topics_req_admin.AddCookie(&admin_uid_cookie)
|
|
|
|
topics_req_admin.AddCookie(&admin_session_cookie)
|
|
|
|
topics_handler := http.HandlerFunc(route_topics)
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2016-12-23 12:35:22 +00:00
|
|
|
forum_w := httptest.NewRecorder()
|
|
|
|
forum_req := httptest.NewRequest("get","/forum/1",bytes.NewReader(nil))
|
|
|
|
forum_req_admin := forum_req
|
|
|
|
forum_req_admin.AddCookie(&admin_uid_cookie)
|
|
|
|
forum_req_admin.AddCookie(&admin_session_cookie)
|
|
|
|
forum_handler := http.HandlerFunc(route_forum)
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2016-12-23 12:35:22 +00:00
|
|
|
forums_w := httptest.NewRecorder()
|
|
|
|
forums_req := httptest.NewRequest("get","/forums/",bytes.NewReader(nil))
|
|
|
|
forums_req_admin := forums_req
|
|
|
|
forums_req_admin.AddCookie(&admin_uid_cookie)
|
|
|
|
forums_req_admin.AddCookie(&admin_session_cookie)
|
|
|
|
forums_handler := http.HandlerFunc(route_forums)
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-01-17 07:55:46 +00:00
|
|
|
if !gloinited {
|
|
|
|
gloinit()
|
|
|
|
}
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-06-10 07:58:15 +00:00
|
|
|
//f, err := os.Create("routes_bench_cpu.prof")
|
|
|
|
//if err != nil {
|
|
|
|
// log.Fatal(err)
|
|
|
|
//}
|
|
|
|
//pprof.StartCPUProfile(f)
|
|
|
|
///defer pprof.StopCPUProfile()
|
|
|
|
///pprof.StopCPUProfile()
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-01-17 07:55:46 +00:00
|
|
|
b.Run("static_recorder", func(b *testing.B) {
|
2017-01-01 15:45:43 +00:00
|
|
|
for i := 0; i < b.N; i++ {
|
2017-02-15 10:49:30 +00:00
|
|
|
//static_w.Code = 200
|
2017-01-01 15:45:43 +00:00
|
|
|
static_w.Body.Reset()
|
|
|
|
static_handler.ServeHTTP(static_w,static_req)
|
2017-02-15 10:49:30 +00:00
|
|
|
//if static_w.Code != 200 {
|
|
|
|
// fmt.Println(static_w.Body)
|
|
|
|
// panic("HTTP Error!")
|
|
|
|
//}
|
2016-12-23 12:35:22 +00:00
|
|
|
}
|
2017-01-01 15:45:43 +00:00
|
|
|
})
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-01-17 07:55:46 +00:00
|
|
|
b.Run("topic_admin_recorder", func(b *testing.B) {
|
|
|
|
//f, err := os.Create("routes_bench_topic_cpu.prof")
|
|
|
|
//if err != nil {
|
|
|
|
// log.Fatal(err)
|
|
|
|
//}
|
|
|
|
//pprof.StartCPUProfile(f)
|
2016-12-17 03:39:53 +00:00
|
|
|
for i := 0; i < b.N; i++ {
|
2016-12-23 12:35:22 +00:00
|
|
|
//topic_w.Code = 200
|
|
|
|
topic_w.Body.Reset()
|
|
|
|
topic_handler.ServeHTTP(topic_w,topic_req_admin)
|
|
|
|
//if topic_w.Code != 200 {
|
|
|
|
// fmt.Println(topic_w.Body)
|
|
|
|
// panic("HTTP Error!")
|
|
|
|
//}
|
2016-12-17 03:39:53 +00:00
|
|
|
}
|
2017-01-17 07:55:46 +00:00
|
|
|
//pprof.StopCPUProfile()
|
2016-12-17 03:39:53 +00:00
|
|
|
})
|
2017-01-17 07:55:46 +00:00
|
|
|
b.Run("topic_guest_recorder", func(b *testing.B) {
|
|
|
|
f, err := os.Create("routes_bench_topic_cpu_2.prof")
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
pprof.StartCPUProfile(f)
|
2016-12-17 03:39:53 +00:00
|
|
|
for i := 0; i < b.N; i++ {
|
2016-12-23 12:35:22 +00:00
|
|
|
//topic_w.Code = 200
|
|
|
|
topic_w.Body.Reset()
|
|
|
|
topic_handler.ServeHTTP(topic_w,topic_req)
|
2016-12-17 03:39:53 +00:00
|
|
|
}
|
2017-01-17 07:55:46 +00:00
|
|
|
pprof.StopCPUProfile()
|
2016-12-17 03:39:53 +00:00
|
|
|
})
|
2017-01-17 07:55:46 +00:00
|
|
|
b.Run("topics_admin_recorder", func(b *testing.B) {
|
2016-12-17 03:39:53 +00:00
|
|
|
for i := 0; i < b.N; i++ {
|
2016-12-23 12:35:22 +00:00
|
|
|
//topics_w.Code = 200
|
|
|
|
topics_w.Body.Reset()
|
|
|
|
topics_handler.ServeHTTP(topics_w,topics_req_admin)
|
2016-12-21 02:30:32 +00:00
|
|
|
}
|
|
|
|
})
|
2017-01-17 07:55:46 +00:00
|
|
|
b.Run("topics_guest_recorder", func(b *testing.B) {
|
2016-12-21 02:30:32 +00:00
|
|
|
for i := 0; i < b.N; i++ {
|
2016-12-23 12:35:22 +00:00
|
|
|
//topics_w.Code = 200
|
|
|
|
topics_w.Body.Reset()
|
|
|
|
topics_handler.ServeHTTP(topics_w,topics_req)
|
|
|
|
}
|
|
|
|
})
|
2017-01-17 07:55:46 +00:00
|
|
|
b.Run("forum_admin_recorder", func(b *testing.B) {
|
2016-12-23 12:35:22 +00:00
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
//forum_w.Code = 200
|
|
|
|
forum_w.Body.Reset()
|
|
|
|
forum_handler.ServeHTTP(forum_w,forum_req_admin)
|
|
|
|
}
|
|
|
|
})
|
2017-01-17 07:55:46 +00:00
|
|
|
b.Run("forum_guest_recorder", func(b *testing.B) {
|
2016-12-23 12:35:22 +00:00
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
//forum_w.Code = 200
|
|
|
|
forum_w.Body.Reset()
|
|
|
|
forum_handler.ServeHTTP(forum_w,forum_req)
|
|
|
|
}
|
|
|
|
})
|
2017-01-17 07:55:46 +00:00
|
|
|
b.Run("forums_admin_recorder", func(b *testing.B) {
|
2016-12-23 12:35:22 +00:00
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
//forums_w.Code = 200
|
|
|
|
forums_w.Body.Reset()
|
|
|
|
forums_handler.ServeHTTP(forums_w,forums_req_admin)
|
|
|
|
}
|
|
|
|
})
|
2017-01-17 07:55:46 +00:00
|
|
|
b.Run("forums_guest_recorder", func(b *testing.B) {
|
2017-06-10 07:58:15 +00:00
|
|
|
//f, err := os.Create("routes_bench_forums_cpu_2.prof")
|
|
|
|
//if err != nil {
|
|
|
|
// log.Fatal(err)
|
|
|
|
//}
|
|
|
|
//pprof.StartCPUProfile(f)
|
2016-12-23 12:35:22 +00:00
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
//forums_w.Code = 200
|
|
|
|
forums_w.Body.Reset()
|
|
|
|
forums_handler.ServeHTTP(forums_w,forums_req)
|
|
|
|
}
|
2017-01-17 07:55:46 +00:00
|
|
|
//pprof.StopCPUProfile()
|
|
|
|
})
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-01-17 07:55:46 +00:00
|
|
|
if !plugins_inited {
|
|
|
|
init_plugins()
|
|
|
|
}
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-01-17 07:55:46 +00:00
|
|
|
b.Run("topic_admin_recorder_with_plugins", func(b *testing.B) {
|
2017-06-10 07:58:15 +00:00
|
|
|
//f, err := os.Create("routes_bench_topic_cpu.prof")
|
|
|
|
//if err != nil {
|
|
|
|
// log.Fatal(err)
|
|
|
|
//}
|
|
|
|
//pprof.StartCPUProfile(f)
|
2017-01-17 07:55:46 +00:00
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
//topic_w.Code = 200
|
|
|
|
topic_w.Body.Reset()
|
|
|
|
topic_handler.ServeHTTP(topic_w,topic_req_admin)
|
|
|
|
//if topic_w.Code != 200 {
|
|
|
|
// fmt.Println(topic_w.Body)
|
|
|
|
// panic("HTTP Error!")
|
|
|
|
//}
|
|
|
|
}
|
|
|
|
//pprof.StopCPUProfile()
|
|
|
|
})
|
|
|
|
b.Run("topic_guest_recorder_with_plugins", func(b *testing.B) {
|
2017-06-10 07:58:15 +00:00
|
|
|
//f, err := os.Create("routes_bench_topic_cpu_2.prof")
|
|
|
|
//if err != nil {
|
|
|
|
// log.Fatal(err)
|
|
|
|
//}
|
|
|
|
//pprof.StartCPUProfile(f)
|
2017-01-17 07:55:46 +00:00
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
//topic_w.Code = 200
|
|
|
|
topic_w.Body.Reset()
|
|
|
|
topic_handler.ServeHTTP(topic_w,topic_req)
|
|
|
|
}
|
|
|
|
//pprof.StopCPUProfile()
|
|
|
|
})
|
|
|
|
b.Run("topics_admin_recorder_with_plugins", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
//topics_w.Code = 200
|
|
|
|
topics_w.Body.Reset()
|
|
|
|
topics_handler.ServeHTTP(topics_w,topics_req_admin)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("topics_guest_recorder_with_plugins", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
//topics_w.Code = 200
|
|
|
|
topics_w.Body.Reset()
|
|
|
|
topics_handler.ServeHTTP(topics_w,topics_req)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("forum_admin_recorder_with_plugins", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
//forum_w.Code = 200
|
|
|
|
forum_w.Body.Reset()
|
|
|
|
forum_handler.ServeHTTP(forum_w,forum_req_admin)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("forum_guest_recorder_with_plugins", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
//forum_w.Code = 200
|
|
|
|
forum_w.Body.Reset()
|
|
|
|
forum_handler.ServeHTTP(forum_w,forum_req)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("forums_admin_recorder_with_plugins", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
//forums_w.Code = 200
|
|
|
|
forums_w.Body.Reset()
|
|
|
|
forums_handler.ServeHTTP(forums_w,forums_req_admin)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("forums_guest_recorder_with_plugins", func(b *testing.B) {
|
2017-06-10 07:58:15 +00:00
|
|
|
//f, err := os.Create("routes_bench_forums_cpu_2.prof")
|
|
|
|
//if err != nil {
|
|
|
|
// log.Fatal(err)
|
|
|
|
//}
|
|
|
|
//pprof.StartCPUProfile(f)
|
2017-01-17 07:55:46 +00:00
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
//forums_w.Code = 200
|
|
|
|
forums_w.Body.Reset()
|
|
|
|
forums_handler.ServeHTTP(forums_w,forums_req)
|
|
|
|
}
|
|
|
|
//pprof.StopCPUProfile()
|
|
|
|
})
|
2017-06-10 07:58:15 +00:00
|
|
|
}*/
|
2017-01-17 07:55:46 +00:00
|
|
|
|
|
|
|
func BenchmarkQueryTopicParallel(b *testing.B) {
|
|
|
|
b.ReportAllocs()
|
|
|
|
if !gloinited {
|
|
|
|
gloinit()
|
|
|
|
}
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-01-17 07:55:46 +00:00
|
|
|
b.RunParallel(func(pb *testing.PB) {
|
2017-02-15 10:49:30 +00:00
|
|
|
tu := TopicUser{Css: no_css_tmpl}
|
2017-01-17 07:55:46 +00:00
|
|
|
for pb.Next() {
|
2017-02-15 10:49:30 +00:00
|
|
|
err := db.QueryRow("select topics.title, topics.content, topics.createdBy, topics.createdAt, topics.is_closed, topics.sticky, topics.parentID, topics.ipaddress, topics.postCount, topics.likeCount, users.name, users.avatar, users.group, users.url_prefix, users.url_name, users.level from topics left join users ON topics.createdBy = users.uid where tid = ?", 1).Scan(&tu.Title, &tu.Content, &tu.CreatedBy, &tu.CreatedAt, &tu.Is_Closed, &tu.Sticky, &tu.ParentID, &tu.IpAddress, &tu.PostCount, &tu.LikeCount, &tu.CreatedByName, &tu.Avatar, &tu.Group, &tu.URLPrefix, &tu.URLName, &tu.Level)
|
2017-06-28 12:05:26 +00:00
|
|
|
if err == ErrNoRows {
|
2017-01-17 07:55:46 +00:00
|
|
|
log.Fatal("No rows found!")
|
|
|
|
return
|
|
|
|
} else if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkQueryPreparedTopicParallel(b *testing.B) {
|
|
|
|
b.ReportAllocs()
|
|
|
|
if !gloinited {
|
|
|
|
gloinit()
|
|
|
|
}
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-01-17 07:55:46 +00:00
|
|
|
b.RunParallel(func(pb *testing.PB) {
|
2017-02-15 10:49:30 +00:00
|
|
|
tu := TopicUser{Css: no_css_tmpl}
|
2017-01-17 07:55:46 +00:00
|
|
|
for pb.Next() {
|
2017-02-15 10:49:30 +00:00
|
|
|
err := get_topic_user_stmt.QueryRow(1).Scan(&tu.Title, &tu.Content, &tu.CreatedBy, &tu.CreatedAt, &tu.Is_Closed, &tu.Sticky, &tu.ParentID, &tu.IpAddress, &tu.PostCount, &tu.LikeCount, &tu.CreatedByName, &tu.Avatar, &tu.Group, &tu.URLPrefix, &tu.URLName, &tu.Level)
|
2017-06-28 12:05:26 +00:00
|
|
|
if err == ErrNoRows {
|
2017-01-17 07:55:46 +00:00
|
|
|
log.Fatal("No rows found!")
|
|
|
|
return
|
|
|
|
} else if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkQueriesSerial(b *testing.B) {
|
|
|
|
b.ReportAllocs()
|
2017-02-15 10:49:30 +00:00
|
|
|
tu := TopicUser{Css: no_css_tmpl}
|
2017-01-17 07:55:46 +00:00
|
|
|
b.Run("topic", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
2017-02-15 10:49:30 +00:00
|
|
|
err := db.QueryRow("select topics.title, topics.content, topics.createdBy, topics.createdAt, topics.is_closed, topics.sticky, topics.parentID, topics.ipaddress, topics.postCount, topics.likeCount, users.name, users.avatar, users.group, users.url_prefix, users.url_name, users.level from topics left join users ON topics.createdBy = users.uid where tid = ?", 1).Scan(&tu.Title, &tu.Content, &tu.CreatedBy, &tu.CreatedAt, &tu.Is_Closed, &tu.Sticky, &tu.ParentID, &tu.IpAddress, &tu.PostCount, &tu.LikeCount, &tu.CreatedByName, &tu.Avatar, &tu.Group, &tu.URLPrefix, &tu.URLName, &tu.Level)
|
2017-06-28 12:05:26 +00:00
|
|
|
if err == ErrNoRows {
|
2017-01-17 07:55:46 +00:00
|
|
|
log.Fatal("No rows found!")
|
|
|
|
return
|
|
|
|
} else if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("topic_replies", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
rows, err := db.Query("select replies.rid, replies.content, replies.createdBy, replies.createdAt, replies.lastEdit, replies.lastEditBy, users.avatar, users.name, users.is_super_admin, users.group, users.url_prefix, users.url_name, users.level, replies.ipaddress from replies left join users ON replies.createdBy = users.uid where tid = ?", 1)
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
for rows.Next() {}
|
|
|
|
err = rows.Err()
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
defer rows.Close()
|
|
|
|
}
|
|
|
|
})
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-01-17 07:55:46 +00:00
|
|
|
replyItem := Reply{Css: no_css_tmpl}
|
2017-02-15 10:49:30 +00:00
|
|
|
var is_super_admin bool
|
|
|
|
var group int
|
2017-01-17 07:55:46 +00:00
|
|
|
b.Run("topic_replies_scan", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
rows, err := db.Query("select replies.rid, replies.content, replies.createdBy, replies.createdAt, replies.lastEdit, replies.lastEditBy, users.avatar, users.name, users.is_super_admin, users.group, users.url_prefix, users.url_name, users.level, replies.ipaddress from replies left join users ON replies.createdBy = users.uid where tid = ?", 1)
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
for rows.Next() {
|
|
|
|
err := rows.Scan(&replyItem.ID, &replyItem.Content, &replyItem.CreatedBy, &replyItem.CreatedAt, &replyItem.LastEdit, &replyItem.LastEditBy, &replyItem.Avatar, &replyItem.CreatedByName, &is_super_admin, &group, &replyItem.URLPrefix, &replyItem.URLName, &replyItem.Level, &replyItem.IpAddress)
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
err = rows.Err()
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
defer rows.Close()
|
|
|
|
}
|
2016-12-23 12:35:22 +00:00
|
|
|
})
|
2016-12-24 13:14:40 +00:00
|
|
|
}
|
|
|
|
|
2017-04-13 09:26:40 +00:00
|
|
|
// Commented until I add logic for profiling the router generator, I'm not sure what the best way of doing that is
|
|
|
|
/*func addEmptyRoutesToMux(routes []string, serveMux *http.ServeMux) {
|
2016-12-24 13:14:40 +00:00
|
|
|
for _, route := range routes {
|
|
|
|
serveMux.HandleFunc(route, func(_ http.ResponseWriter,_ *http.Request){})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-15 10:49:30 +00:00
|
|
|
func BenchmarkDefaultGoRouterSerial(b *testing.B) {
|
2016-12-24 13:14:40 +00:00
|
|
|
w := httptest.NewRecorder()
|
|
|
|
req := httptest.NewRequest("get","/topics/",bytes.NewReader(nil))
|
|
|
|
routes := make([]string, 0)
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2016-12-24 13:14:40 +00:00
|
|
|
routes = append(routes,"/test/")
|
2016-12-23 12:35:22 +00:00
|
|
|
serveMux := http.NewServeMux()
|
2016-12-24 13:14:40 +00:00
|
|
|
serveMux.HandleFunc("/test/", func(_ http.ResponseWriter,_ *http.Request){})
|
|
|
|
b.Run("one-route", func(b *testing.B) {
|
2016-12-23 12:35:22 +00:00
|
|
|
for i := 0; i < b.N; i++ {
|
2016-12-24 13:14:40 +00:00
|
|
|
req = httptest.NewRequest("get",routes[rand.Intn(len(routes))],bytes.NewReader(nil))
|
|
|
|
serveMux.ServeHTTP(w,req)
|
|
|
|
}
|
|
|
|
})
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2016-12-24 13:14:40 +00:00
|
|
|
routes = append(routes,"/topic/")
|
|
|
|
routes = append(routes,"/forums/")
|
|
|
|
routes = append(routes,"/forum/")
|
|
|
|
routes = append(routes,"/panel/")
|
|
|
|
serveMux = http.NewServeMux()
|
|
|
|
addEmptyRoutesToMux(routes, serveMux)
|
|
|
|
b.Run("five-routes", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
req = httptest.NewRequest("get",routes[rand.Intn(len(routes))],bytes.NewReader(nil))
|
|
|
|
serveMux.ServeHTTP(w,req)
|
|
|
|
}
|
|
|
|
})
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2016-12-24 13:14:40 +00:00
|
|
|
serveMux = http.NewServeMux()
|
|
|
|
routes = append(routes,"/panel/plugins/")
|
|
|
|
routes = append(routes,"/panel/groups/")
|
|
|
|
routes = append(routes,"/panel/settings/")
|
|
|
|
routes = append(routes,"/panel/users/")
|
|
|
|
routes = append(routes,"/panel/forums/")
|
|
|
|
addEmptyRoutesToMux(routes, serveMux)
|
|
|
|
b.Run("ten-routes", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
req = httptest.NewRequest("get",routes[rand.Intn(len(routes))],bytes.NewReader(nil))
|
|
|
|
serveMux.ServeHTTP(w,req)
|
|
|
|
}
|
|
|
|
})
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2016-12-24 13:14:40 +00:00
|
|
|
serveMux = http.NewServeMux()
|
|
|
|
routes = append(routes,"/panel/forums/create/submit/")
|
|
|
|
routes = append(routes,"/panel/forums/delete/")
|
|
|
|
routes = append(routes,"/users/ban/")
|
|
|
|
routes = append(routes,"/panel/users/edit/")
|
|
|
|
routes = append(routes,"/panel/forums/create/")
|
|
|
|
routes = append(routes,"/users/unban/")
|
|
|
|
routes = append(routes,"/pages/")
|
|
|
|
routes = append(routes,"/users/activate/")
|
|
|
|
routes = append(routes,"/panel/forums/edit/submit/")
|
|
|
|
routes = append(routes,"/panel/plugins/activate/")
|
|
|
|
addEmptyRoutesToMux(routes, serveMux)
|
|
|
|
b.Run("twenty-routes", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
req = httptest.NewRequest("get",routes[rand.Intn(len(routes))],bytes.NewReader(nil))
|
|
|
|
serveMux.ServeHTTP(w,req)
|
|
|
|
}
|
|
|
|
})
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2016-12-24 13:14:40 +00:00
|
|
|
serveMux = http.NewServeMux()
|
|
|
|
routes = append(routes,"/panel/plugins/deactivate/")
|
|
|
|
routes = append(routes,"/panel/plugins/install/")
|
|
|
|
routes = append(routes,"/panel/plugins/uninstall/")
|
|
|
|
routes = append(routes,"/panel/templates/")
|
|
|
|
routes = append(routes,"/panel/templates/edit/")
|
|
|
|
routes = append(routes,"/panel/templates/create/")
|
|
|
|
routes = append(routes,"/panel/templates/delete/")
|
|
|
|
routes = append(routes,"/panel/templates/edit/submit/")
|
|
|
|
routes = append(routes,"/panel/themes/")
|
|
|
|
routes = append(routes,"/panel/themes/edit/")
|
|
|
|
addEmptyRoutesToMux(routes, serveMux)
|
|
|
|
b.Run("thirty-routes", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
req = httptest.NewRequest("get",routes[rand.Intn(len(routes))],bytes.NewReader(nil))
|
|
|
|
serveMux.ServeHTTP(w,req)
|
|
|
|
}
|
|
|
|
})
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2016-12-24 13:14:40 +00:00
|
|
|
serveMux = http.NewServeMux()
|
|
|
|
routes = append(routes,"/panel/themes/create/")
|
|
|
|
routes = append(routes,"/panel/themes/delete/")
|
|
|
|
routes = append(routes,"/panel/themes/delete/submit/")
|
|
|
|
routes = append(routes,"/panel/templates/create/submit/")
|
|
|
|
routes = append(routes,"/panel/templates/delete/submit/")
|
|
|
|
routes = append(routes,"/panel/widgets/")
|
|
|
|
routes = append(routes,"/panel/widgets/edit/")
|
|
|
|
routes = append(routes,"/panel/widgets/activate/")
|
|
|
|
routes = append(routes,"/panel/widgets/deactivate/")
|
|
|
|
routes = append(routes,"/panel/magical/wombat/path")
|
|
|
|
addEmptyRoutesToMux(routes, serveMux)
|
|
|
|
b.Run("forty-routes", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
req = httptest.NewRequest("get",routes[rand.Intn(len(routes))],bytes.NewReader(nil))
|
|
|
|
serveMux.ServeHTTP(w,req)
|
|
|
|
}
|
|
|
|
})
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2016-12-24 13:14:40 +00:00
|
|
|
serveMux = http.NewServeMux()
|
|
|
|
routes = append(routes,"/report/")
|
|
|
|
routes = append(routes,"/report/submit/")
|
|
|
|
routes = append(routes,"/topic/create/submit/")
|
|
|
|
routes = append(routes,"/topics/create/")
|
|
|
|
routes = append(routes,"/overview/")
|
|
|
|
routes = append(routes,"/uploads/")
|
|
|
|
routes = append(routes,"/static/")
|
|
|
|
routes = append(routes,"/reply/edit/submit/")
|
|
|
|
routes = append(routes,"/reply/delete/submit/")
|
|
|
|
routes = append(routes,"/topic/edit/submit/")
|
|
|
|
addEmptyRoutesToMux(routes, serveMux)
|
|
|
|
b.Run("fifty-routes", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
req = httptest.NewRequest("get",routes[rand.Intn(len(routes))],bytes.NewReader(nil))
|
|
|
|
serveMux.ServeHTTP(w,req)
|
|
|
|
}
|
|
|
|
})
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2016-12-24 13:14:40 +00:00
|
|
|
serveMux = http.NewServeMux()
|
|
|
|
routes = append(routes,"/topic/delete/submit/")
|
|
|
|
routes = append(routes,"/topic/stick/submit/")
|
|
|
|
routes = append(routes,"/topic/unstick/submit/")
|
|
|
|
routes = append(routes,"/accounts/login/")
|
|
|
|
routes = append(routes,"/accounts/create/")
|
|
|
|
routes = append(routes,"/accounts/logout/")
|
|
|
|
routes = append(routes,"/accounts/login/submit/")
|
|
|
|
routes = append(routes,"/accounts/create/submit/")
|
|
|
|
routes = append(routes,"/user/edit/critical/")
|
|
|
|
routes = append(routes,"/user/edit/critical/submit/")
|
|
|
|
addEmptyRoutesToMux(routes, serveMux)
|
|
|
|
b.Run("sixty-routes", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
req = httptest.NewRequest("get",routes[rand.Intn(len(routes))],bytes.NewReader(nil))
|
|
|
|
serveMux.ServeHTTP(w,req)
|
|
|
|
}
|
|
|
|
})
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2016-12-24 13:14:40 +00:00
|
|
|
serveMux = http.NewServeMux()
|
|
|
|
routes = append(routes,"/user/edit/avatar/")
|
|
|
|
routes = append(routes,"/user/edit/avatar/submit/")
|
|
|
|
routes = append(routes,"/user/edit/username/")
|
|
|
|
routes = append(routes,"/user/edit/username/submit/")
|
|
|
|
routes = append(routes,"/profile/reply/create/")
|
|
|
|
routes = append(routes,"/profile/reply/edit/submit/")
|
|
|
|
routes = append(routes,"/profile/reply/delete/submit/")
|
|
|
|
routes = append(routes,"/arcane/tower/")
|
|
|
|
routes = append(routes,"/magical/kingdom/")
|
|
|
|
routes = append(routes,"/insert/name/here/")
|
|
|
|
addEmptyRoutesToMux(routes, serveMux)
|
|
|
|
b.Run("seventy-routes", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
req = httptest.NewRequest("get",routes[rand.Intn(len(routes))],bytes.NewReader(nil))
|
|
|
|
serveMux.ServeHTTP(w,req)
|
2016-12-17 03:39:53 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
2016-12-23 12:35:22 +00:00
|
|
|
|
2017-01-03 07:47:31 +00:00
|
|
|
func addEmptyRoutesToCustom(routes []string, router *Router) {
|
|
|
|
for _, route := range routes {
|
|
|
|
router.HandleFunc(route, func(_ http.ResponseWriter,_ *http.Request){})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-15 10:49:30 +00:00
|
|
|
func BenchmarkCustomRouterSerial(b *testing.B) {
|
2017-01-03 07:47:31 +00:00
|
|
|
w := httptest.NewRecorder()
|
|
|
|
req := httptest.NewRequest("get","/topics/",bytes.NewReader(nil))
|
|
|
|
routes := make([]string, 0)
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-01-03 07:47:31 +00:00
|
|
|
routes = append(routes,"/test/")
|
|
|
|
router := NewRouter()
|
|
|
|
router.HandleFunc("/test/", func(_ http.ResponseWriter,_ *http.Request){})
|
|
|
|
b.Run("one-route", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
req = httptest.NewRequest("get",routes[rand.Intn(len(routes))],bytes.NewReader(nil))
|
|
|
|
router.ServeHTTP(w,req)
|
|
|
|
}
|
|
|
|
})
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-01-03 07:47:31 +00:00
|
|
|
routes = append(routes,"/topic/")
|
|
|
|
routes = append(routes,"/forums/")
|
|
|
|
routes = append(routes,"/forum/")
|
|
|
|
routes = append(routes,"/panel/")
|
|
|
|
router = NewRouter()
|
|
|
|
addEmptyRoutesToCustom(routes, router)
|
|
|
|
b.Run("five-routes", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
req = httptest.NewRequest("get",routes[rand.Intn(len(routes))],bytes.NewReader(nil))
|
|
|
|
router.ServeHTTP(w,req)
|
|
|
|
}
|
|
|
|
})
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-01-03 07:47:31 +00:00
|
|
|
router = NewRouter()
|
|
|
|
routes = append(routes,"/panel/plugins/")
|
|
|
|
routes = append(routes,"/panel/groups/")
|
|
|
|
routes = append(routes,"/panel/settings/")
|
|
|
|
routes = append(routes,"/panel/users/")
|
|
|
|
routes = append(routes,"/panel/forums/")
|
|
|
|
addEmptyRoutesToCustom(routes, router)
|
|
|
|
b.Run("ten-routes", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
req = httptest.NewRequest("get",routes[rand.Intn(len(routes))],bytes.NewReader(nil))
|
|
|
|
router.ServeHTTP(w,req)
|
|
|
|
}
|
|
|
|
})
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-01-03 07:47:31 +00:00
|
|
|
router = NewRouter()
|
|
|
|
routes = append(routes,"/panel/forums/create/submit/")
|
|
|
|
routes = append(routes,"/panel/forums/delete/")
|
|
|
|
routes = append(routes,"/users/ban/")
|
|
|
|
routes = append(routes,"/panel/users/edit/")
|
|
|
|
routes = append(routes,"/panel/forums/create/")
|
|
|
|
routes = append(routes,"/users/unban/")
|
|
|
|
routes = append(routes,"/pages/")
|
|
|
|
routes = append(routes,"/users/activate/")
|
|
|
|
routes = append(routes,"/panel/forums/edit/submit/")
|
|
|
|
routes = append(routes,"/panel/plugins/activate/")
|
|
|
|
addEmptyRoutesToCustom(routes, router)
|
|
|
|
b.Run("twenty-routes", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
req = httptest.NewRequest("get",routes[rand.Intn(len(routes))],bytes.NewReader(nil))
|
|
|
|
router.ServeHTTP(w,req)
|
|
|
|
}
|
|
|
|
})
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-01-03 07:47:31 +00:00
|
|
|
router = NewRouter()
|
|
|
|
routes = append(routes,"/panel/plugins/deactivate/")
|
|
|
|
routes = append(routes,"/panel/plugins/install/")
|
|
|
|
routes = append(routes,"/panel/plugins/uninstall/")
|
|
|
|
routes = append(routes,"/panel/templates/")
|
|
|
|
routes = append(routes,"/panel/templates/edit/")
|
|
|
|
routes = append(routes,"/panel/templates/create/")
|
|
|
|
routes = append(routes,"/panel/templates/delete/")
|
|
|
|
routes = append(routes,"/panel/templates/edit/submit/")
|
|
|
|
routes = append(routes,"/panel/themes/")
|
|
|
|
routes = append(routes,"/panel/themes/edit/")
|
|
|
|
addEmptyRoutesToCustom(routes, router)
|
|
|
|
b.Run("thirty-routes", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
req = httptest.NewRequest("get",routes[rand.Intn(len(routes))],bytes.NewReader(nil))
|
|
|
|
router.ServeHTTP(w,req)
|
|
|
|
}
|
|
|
|
})
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-01-03 07:47:31 +00:00
|
|
|
router = NewRouter()
|
|
|
|
routes = append(routes,"/panel/themes/create/")
|
|
|
|
routes = append(routes,"/panel/themes/delete/")
|
|
|
|
routes = append(routes,"/panel/themes/delete/submit/")
|
|
|
|
routes = append(routes,"/panel/templates/create/submit/")
|
|
|
|
routes = append(routes,"/panel/templates/delete/submit/")
|
|
|
|
routes = append(routes,"/panel/widgets/")
|
|
|
|
routes = append(routes,"/panel/widgets/edit/")
|
|
|
|
routes = append(routes,"/panel/widgets/activate/")
|
|
|
|
routes = append(routes,"/panel/widgets/deactivate/")
|
|
|
|
routes = append(routes,"/panel/magical/wombat/path")
|
|
|
|
addEmptyRoutesToCustom(routes, router)
|
|
|
|
b.Run("forty-routes", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
req = httptest.NewRequest("get",routes[rand.Intn(len(routes))],bytes.NewReader(nil))
|
|
|
|
router.ServeHTTP(w,req)
|
|
|
|
}
|
|
|
|
})
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-01-03 07:47:31 +00:00
|
|
|
router = NewRouter()
|
|
|
|
routes = append(routes,"/report/")
|
|
|
|
routes = append(routes,"/report/submit/")
|
|
|
|
routes = append(routes,"/topic/create/submit/")
|
|
|
|
routes = append(routes,"/topics/create/")
|
|
|
|
routes = append(routes,"/overview/")
|
|
|
|
routes = append(routes,"/uploads/")
|
|
|
|
routes = append(routes,"/static/")
|
|
|
|
routes = append(routes,"/reply/edit/submit/")
|
|
|
|
routes = append(routes,"/reply/delete/submit/")
|
|
|
|
routes = append(routes,"/topic/edit/submit/")
|
|
|
|
addEmptyRoutesToCustom(routes, router)
|
|
|
|
b.Run("fifty-routes", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
req = httptest.NewRequest("get",routes[rand.Intn(len(routes))],bytes.NewReader(nil))
|
|
|
|
router.ServeHTTP(w,req)
|
|
|
|
}
|
|
|
|
})
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-01-03 07:47:31 +00:00
|
|
|
router = NewRouter()
|
|
|
|
routes = append(routes,"/topic/delete/submit/")
|
|
|
|
routes = append(routes,"/topic/stick/submit/")
|
|
|
|
routes = append(routes,"/topic/unstick/submit/")
|
|
|
|
routes = append(routes,"/accounts/login/")
|
|
|
|
routes = append(routes,"/accounts/create/")
|
|
|
|
routes = append(routes,"/accounts/logout/")
|
|
|
|
routes = append(routes,"/accounts/login/submit/")
|
|
|
|
routes = append(routes,"/accounts/create/submit/")
|
|
|
|
routes = append(routes,"/user/edit/critical/")
|
|
|
|
routes = append(routes,"/user/edit/critical/submit/")
|
|
|
|
addEmptyRoutesToCustom(routes, router)
|
|
|
|
b.Run("sixty-routes", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
req = httptest.NewRequest("get",routes[rand.Intn(len(routes))],bytes.NewReader(nil))
|
|
|
|
router.ServeHTTP(w,req)
|
|
|
|
}
|
|
|
|
})
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-01-03 07:47:31 +00:00
|
|
|
router = NewRouter()
|
|
|
|
routes = append(routes,"/user/edit/avatar/")
|
|
|
|
routes = append(routes,"/user/edit/avatar/submit/")
|
|
|
|
routes = append(routes,"/user/edit/username/")
|
|
|
|
routes = append(routes,"/user/edit/username/submit/")
|
|
|
|
routes = append(routes,"/profile/reply/create/")
|
|
|
|
routes = append(routes,"/profile/reply/edit/submit/")
|
|
|
|
routes = append(routes,"/profile/reply/delete/submit/")
|
|
|
|
routes = append(routes,"/arcane/tower/")
|
|
|
|
routes = append(routes,"/magical/kingdom/")
|
|
|
|
routes = append(routes,"/insert/name/here/")
|
|
|
|
addEmptyRoutesToCustom(routes, router)
|
|
|
|
b.Run("seventy-routes", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
req = httptest.NewRequest("get",routes[rand.Intn(len(routes))],bytes.NewReader(nil))
|
|
|
|
router.ServeHTTP(w,req)
|
|
|
|
}
|
|
|
|
})
|
2017-04-13 09:26:40 +00:00
|
|
|
}*/
|
2017-01-03 07:47:31 +00:00
|
|
|
|
2017-02-15 10:49:30 +00:00
|
|
|
func BenchmarkParserSerial(b *testing.B) {
|
2017-01-05 14:41:14 +00:00
|
|
|
b.ReportAllocs()
|
|
|
|
b.Run("empty_post", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
_ = parse_message("")
|
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("short_post", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
_ = parse_message("Hey everyone, how's it going?")
|
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("one_smily", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
_ = parse_message("Hey everyone, how's it going? :)")
|
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("five_smilies", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
_ = parse_message("Hey everyone, how's it going? :):):):):)")
|
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("ten_smilies", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
_ = parse_message("Hey everyone, how's it going? :):):):):):):):):):)")
|
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("twenty_smilies", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
_ = parse_message("Hey everyone, how's it going? :):):):):):):):):):):):):):):):):):):):)")
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2017-02-15 10:49:30 +00:00
|
|
|
func BenchmarkBBCodePluginWithRegexpSerial(b *testing.B) {
|
2017-01-05 14:41:14 +00:00
|
|
|
b.ReportAllocs()
|
|
|
|
b.Run("empty_post", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
2017-01-07 06:31:04 +00:00
|
|
|
_ = bbcode_regex_parse("")
|
2017-01-05 14:41:14 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("short_post", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
2017-01-07 06:31:04 +00:00
|
|
|
_ = bbcode_regex_parse("Hey everyone, how's it going?")
|
2017-01-05 14:41:14 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("one_smily", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
2017-01-07 06:31:04 +00:00
|
|
|
_ = bbcode_regex_parse("Hey everyone, how's it going? :)")
|
2017-01-05 14:41:14 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("five_smilies", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
2017-01-07 06:31:04 +00:00
|
|
|
_ = bbcode_regex_parse("Hey everyone, how's it going? :):):):):)")
|
2017-01-05 14:41:14 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("ten_smilies", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
2017-01-07 06:31:04 +00:00
|
|
|
_ = bbcode_regex_parse("Hey everyone, how's it going? :):):):):):):):):):)")
|
2017-01-05 14:41:14 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("twenty_smilies", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
2017-01-07 06:31:04 +00:00
|
|
|
_ = bbcode_regex_parse("Hey everyone, how's it going? :):):):):):):):):):):):):):):):):):):):)")
|
2017-01-05 14:41:14 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("one_bold", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
2017-01-07 06:31:04 +00:00
|
|
|
_ = bbcode_regex_parse("[b]H[/b]ey everyone, how's it going?")
|
2017-01-05 14:41:14 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("five_bold", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
2017-01-07 06:31:04 +00:00
|
|
|
_ = bbcode_regex_parse("[b]H[/b][b]e[/b][b]y[/b] [b]e[/b][b]v[/b]eryone, how's it going?")
|
2017-01-05 14:41:14 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("ten_bold", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
2017-01-07 06:31:04 +00:00
|
|
|
_ = bbcode_regex_parse("[b]H[/b][b]e[/b][b]y[/b] [b]e[/b][b]v[/b][b]e[/b][b]r[/b][b]y[/b][b]o[/b][b]n[/b]e, how's it going?")
|
2017-01-05 14:41:14 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2017-02-15 10:49:30 +00:00
|
|
|
func BenchmarkBBCodePluginWithoutCodeTagSerial(b *testing.B) {
|
2017-01-05 14:41:14 +00:00
|
|
|
b.ReportAllocs()
|
|
|
|
b.Run("empty_post", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
2017-01-07 06:31:04 +00:00
|
|
|
_ = bbcode_parse_without_code("")
|
2017-01-05 14:41:14 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("short_post", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
2017-01-07 06:31:04 +00:00
|
|
|
_ = bbcode_parse_without_code("Hey everyone, how's it going?")
|
2017-01-05 14:41:14 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("one_smily", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
2017-01-07 06:31:04 +00:00
|
|
|
_ = bbcode_parse_without_code("Hey everyone, how's it going? :)")
|
2017-01-05 14:41:14 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("five_smilies", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
2017-01-07 06:31:04 +00:00
|
|
|
_ = bbcode_parse_without_code("Hey everyone, how's it going? :):):):):)")
|
2017-01-05 14:41:14 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("ten_smilies", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
2017-01-07 06:31:04 +00:00
|
|
|
_ = bbcode_parse_without_code("Hey everyone, how's it going? :):):):):):):):):):)")
|
2017-01-05 14:41:14 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("twenty_smilies", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
2017-01-07 06:31:04 +00:00
|
|
|
_ = bbcode_parse_without_code("Hey everyone, how's it going? :):):):):):):):):):):):):):):):):):):):)")
|
2017-01-05 14:41:14 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("one_bold", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
2017-01-07 06:31:04 +00:00
|
|
|
_ = bbcode_parse_without_code("[b]H[/b]ey everyone, how's it going?")
|
2017-01-05 14:41:14 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("five_bold", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
2017-01-07 06:31:04 +00:00
|
|
|
_ = bbcode_parse_without_code("[b]H[/b][b]e[/b][b]y[/b] [b]e[/b][b]v[/b]eryone, how's it going?")
|
2017-01-05 14:41:14 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("ten_bold", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
2017-01-07 06:31:04 +00:00
|
|
|
_ = bbcode_parse_without_code("[b]H[/b][b]e[/b][b]y[/b] [b]e[/b][b]v[/b][b]e[/b][b]r[/b][b]y[/b][b]o[/b][b]n[/b]e, how's it going?")
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2017-02-15 10:49:30 +00:00
|
|
|
func BenchmarkBBCodePluginWithFullParserSerial(b *testing.B) {
|
2017-01-07 06:31:04 +00:00
|
|
|
b.ReportAllocs()
|
|
|
|
b.Run("empty_post", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
_ = bbcode_full_parse("")
|
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("short_post", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
_ = bbcode_full_parse("Hey everyone, how's it going?")
|
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("one_smily", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
_ = bbcode_full_parse("Hey everyone, how's it going? :)")
|
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("five_smilies", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
_ = bbcode_full_parse("Hey everyone, how's it going? :):):):):)")
|
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("ten_smilies", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
_ = bbcode_full_parse("Hey everyone, how's it going? :):):):):):):):):):)")
|
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("twenty_smilies", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
_ = bbcode_full_parse("Hey everyone, how's it going? :):):):):):):):):):):):):):):):):):):):)")
|
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("one_bold", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
_ = bbcode_full_parse("[b]H[/b]ey everyone, how's it going?")
|
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("five_bold", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
_ = bbcode_full_parse("[b]H[/b][b]e[/b][b]y[/b] [b]e[/b][b]v[/b]eryone, how's it going?")
|
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("ten_bold", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
_ = bbcode_full_parse("[b]H[/b][b]e[/b][b]y[/b] [b]e[/b][b]v[/b][b]e[/b][b]r[/b][b]y[/b][b]o[/b][b]n[/b]e, how's it going?")
|
2017-01-05 14:41:14 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2017-01-12 02:55:08 +00:00
|
|
|
func TestLevels(t *testing.T) {
|
|
|
|
levels := getLevels(40)
|
|
|
|
for level, score := range levels {
|
|
|
|
sscore := strconv.FormatFloat(score, 'f', -1, 64)
|
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
|
|
|
t.Log("Level: " + strconv.Itoa(level) + " Score: " + sscore)
|
2017-01-12 02:55:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-12 11:05:18 +00:00
|
|
|
// TO-DO: Make this compatible with the changes to the router
|
|
|
|
/*
|
2017-02-15 10:49:30 +00:00
|
|
|
func TestStaticRoute(t *testing.T) {
|
|
|
|
if !gloinited {
|
|
|
|
gloinit()
|
|
|
|
}
|
|
|
|
if !plugins_inited {
|
|
|
|
init_plugins()
|
|
|
|
}
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-02-15 10:49:30 +00:00
|
|
|
static_w := httptest.NewRecorder()
|
|
|
|
static_req := httptest.NewRequest("get","/static/global.js",bytes.NewReader(nil))
|
|
|
|
static_handler := http.HandlerFunc(route_static)
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-02-15 10:49:30 +00:00
|
|
|
static_handler.ServeHTTP(static_w,static_req)
|
|
|
|
if static_w.Code != 200 {
|
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
|
|
|
t.Fatal(static_w.Body)
|
2017-02-15 10:49:30 +00:00
|
|
|
}
|
|
|
|
}
|
2017-07-12 11:05:18 +00:00
|
|
|
*/
|
2017-02-15 10:49:30 +00:00
|
|
|
|
2017-06-10 07:58:15 +00:00
|
|
|
/*func TestTopicAdminRoute(t *testing.T) {
|
2017-02-15 10:49:30 +00:00
|
|
|
if !gloinited {
|
|
|
|
gloinit()
|
|
|
|
}
|
|
|
|
if !plugins_inited {
|
|
|
|
init_plugins()
|
|
|
|
}
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-02-15 10:49:30 +00:00
|
|
|
admin, err := users.CascadeGet(1)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
if !admin.Is_Admin {
|
|
|
|
panic("UID1 is not an admin")
|
|
|
|
}
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-02-15 10:49:30 +00:00
|
|
|
admin_uid_cookie := http.Cookie{Name:"uid",Value:"1",Path:"/",MaxAge: year}
|
|
|
|
admin_session_cookie := http.Cookie{Name:"session",Value: admin.Session,Path:"/",MaxAge: year}
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-02-15 10:49:30 +00:00
|
|
|
topic_w := httptest.NewRecorder()
|
|
|
|
topic_req := httptest.NewRequest("get","/topic/1",bytes.NewReader(nil))
|
|
|
|
topic_req_admin := topic_req
|
|
|
|
topic_req_admin.AddCookie(&admin_uid_cookie)
|
|
|
|
topic_req_admin.AddCookie(&admin_session_cookie)
|
|
|
|
topic_handler := http.HandlerFunc(route_topic_id)
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-02-15 10:49:30 +00:00
|
|
|
topic_handler.ServeHTTP(topic_w,topic_req_admin)
|
|
|
|
if topic_w.Code != 200 {
|
|
|
|
fmt.Println(topic_w.Body)
|
|
|
|
panic("HTTP Error!")
|
|
|
|
}
|
|
|
|
fmt.Println("No problems found in the topic-admin route!")
|
2017-06-10 07:58:15 +00:00
|
|
|
}*/
|
2017-02-15 10:49:30 +00:00
|
|
|
|
2017-06-10 07:58:15 +00:00
|
|
|
/*func TestTopicGuestRoute(t *testing.T) {
|
2017-02-15 10:49:30 +00:00
|
|
|
if !gloinited {
|
|
|
|
gloinit()
|
|
|
|
}
|
|
|
|
if !plugins_inited {
|
|
|
|
init_plugins()
|
|
|
|
}
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-02-15 10:49:30 +00:00
|
|
|
topic_w := httptest.NewRecorder()
|
|
|
|
topic_req := httptest.NewRequest("get","/topic/1",bytes.NewReader(nil))
|
|
|
|
topic_handler := http.HandlerFunc(route_topic_id)
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-02-15 10:49:30 +00:00
|
|
|
topic_handler.ServeHTTP(topic_w,topic_req)
|
|
|
|
if topic_w.Code != 200 {
|
|
|
|
fmt.Println(topic_w.Body)
|
|
|
|
panic("HTTP Error!")
|
|
|
|
}
|
|
|
|
fmt.Println("No problems found in the topic-guest route!")
|
2017-06-10 07:58:15 +00:00
|
|
|
}*/
|
2017-02-15 10:49:30 +00:00
|
|
|
|
2017-07-12 11:05:18 +00:00
|
|
|
// TO-DO: Make these routes compatible with the changes to the router
|
|
|
|
/*
|
2017-02-15 10:49:30 +00:00
|
|
|
func TestForumsAdminRoute(t *testing.T) {
|
|
|
|
if !gloinited {
|
|
|
|
gloinit()
|
|
|
|
}
|
|
|
|
if !plugins_inited {
|
|
|
|
init_plugins()
|
|
|
|
}
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-02-15 10:49:30 +00:00
|
|
|
admin, err := users.CascadeGet(1)
|
|
|
|
if err != nil {
|
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
|
|
|
t.Fatal(err)
|
2017-02-15 10:49:30 +00:00
|
|
|
}
|
|
|
|
if !admin.Is_Admin {
|
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
|
|
|
t.Fatal("UID1 is not an admin")
|
2017-02-15 10:49:30 +00:00
|
|
|
}
|
|
|
|
admin_uid_cookie := http.Cookie{Name:"uid",Value:"1",Path:"/",MaxAge: year}
|
|
|
|
admin_session_cookie := http.Cookie{Name:"session",Value: admin.Session,Path:"/",MaxAge: year}
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-02-15 10:49:30 +00:00
|
|
|
forums_w := httptest.NewRecorder()
|
|
|
|
forums_req := httptest.NewRequest("get","/forums/",bytes.NewReader(nil))
|
|
|
|
forums_req_admin := forums_req
|
|
|
|
forums_req_admin.AddCookie(&admin_uid_cookie)
|
|
|
|
forums_req_admin.AddCookie(&admin_session_cookie)
|
|
|
|
forums_handler := http.HandlerFunc(route_forums)
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-02-15 10:49:30 +00:00
|
|
|
forums_handler.ServeHTTP(forums_w,forums_req_admin)
|
|
|
|
if forums_w.Code != 200 {
|
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
|
|
|
t.Fatal(forums_w.Body)
|
2017-02-15 10:49:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestForumsGuestRoute(t *testing.T) {
|
|
|
|
if !gloinited {
|
|
|
|
gloinit()
|
|
|
|
}
|
|
|
|
if !plugins_inited {
|
|
|
|
init_plugins()
|
|
|
|
}
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-02-15 10:49:30 +00:00
|
|
|
forums_w := httptest.NewRecorder()
|
|
|
|
forums_req := httptest.NewRequest("get","/forums/",bytes.NewReader(nil))
|
|
|
|
forums_handler := http.HandlerFunc(route_forums)
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-02-15 10:49:30 +00:00
|
|
|
forums_handler.ServeHTTP(forums_w,forums_req)
|
|
|
|
if forums_w.Code != 200 {
|
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
|
|
|
t.Fatal(forums_w.Body)
|
2017-02-15 10:49:30 +00:00
|
|
|
}
|
|
|
|
}
|
2017-07-12 11:05:18 +00:00
|
|
|
*/
|
2017-02-15 10:49:30 +00:00
|
|
|
|
2017-06-10 07:58:15 +00:00
|
|
|
/*func TestForumAdminRoute(t *testing.T) {
|
2017-02-15 10:49:30 +00:00
|
|
|
if !gloinited {
|
|
|
|
gloinit()
|
|
|
|
}
|
|
|
|
if !plugins_inited {
|
|
|
|
init_plugins()
|
|
|
|
}
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-02-15 10:49:30 +00:00
|
|
|
admin, err := users.CascadeGet(1)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
if !admin.Is_Admin {
|
|
|
|
panic("UID1 is not an admin")
|
|
|
|
}
|
|
|
|
admin_uid_cookie := http.Cookie{Name:"uid",Value:"1",Path:"/",MaxAge: year}
|
|
|
|
admin_session_cookie := http.Cookie{Name:"session",Value: admin.Session,Path:"/",MaxAge: year}
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-02-15 10:49:30 +00:00
|
|
|
forum_w := httptest.NewRecorder()
|
2017-02-15 15:29:05 +00:00
|
|
|
forum_req := httptest.NewRequest("get","/forum/1",bytes.NewReader(nil))
|
2017-02-15 10:49:30 +00:00
|
|
|
forum_req_admin := forum_req
|
|
|
|
forum_req_admin.AddCookie(&admin_uid_cookie)
|
|
|
|
forum_req_admin.AddCookie(&admin_session_cookie)
|
|
|
|
forum_handler := http.HandlerFunc(route_forum)
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-02-15 10:49:30 +00:00
|
|
|
forum_handler.ServeHTTP(forum_w,forum_req_admin)
|
|
|
|
if forum_w.Code != 200 {
|
|
|
|
fmt.Println(forum_w.Body)
|
|
|
|
panic("HTTP Error!")
|
|
|
|
}
|
|
|
|
fmt.Println("No problems found in the forum-admin route!")
|
2017-06-10 07:58:15 +00:00
|
|
|
}*/
|
2017-02-15 10:49:30 +00:00
|
|
|
|
2017-06-10 07:58:15 +00:00
|
|
|
/*func TestForumGuestRoute(t *testing.T) {
|
2017-02-15 10:49:30 +00:00
|
|
|
if !gloinited {
|
|
|
|
gloinit()
|
|
|
|
}
|
|
|
|
if !plugins_inited {
|
|
|
|
init_plugins()
|
|
|
|
}
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-02-15 10:49:30 +00:00
|
|
|
forum_w := httptest.NewRecorder()
|
|
|
|
forum_req := httptest.NewRequest("get","/forum/2",bytes.NewReader(nil))
|
|
|
|
forum_handler := http.HandlerFunc(route_forum)
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-02-15 10:49:30 +00:00
|
|
|
forum_handler.ServeHTTP(forum_w,forum_req)
|
|
|
|
if forum_w.Code != 200 {
|
|
|
|
fmt.Println(forum_w.Body)
|
|
|
|
panic("HTTP Error!")
|
|
|
|
}
|
|
|
|
fmt.Println("No problems found in the forum-guest route!")
|
2017-06-10 07:58:15 +00:00
|
|
|
}*/
|
2017-02-15 10:49:30 +00:00
|
|
|
|
2017-02-28 09:27:28 +00:00
|
|
|
/*func TestAlerts(t *testing.T) {
|
|
|
|
if !gloinited {
|
|
|
|
gloinit()
|
|
|
|
}
|
|
|
|
if !plugins_inited {
|
|
|
|
init_plugins()
|
|
|
|
}
|
|
|
|
db = db_test
|
|
|
|
alert_w := httptest.NewRecorder()
|
2017-03-01 11:36:50 +00:00
|
|
|
alert_req := httptest.NewRequest("get","/api/?action=get&module=alerts&format=json",bytes.NewReader(nil))
|
2017-02-28 09:27:28 +00:00
|
|
|
alert_handler := http.HandlerFunc(route_api)
|
|
|
|
//testdb.StubQuery()
|
|
|
|
testdb.SetQueryFunc(func(query string) (result sql.Rows, err error) {
|
|
|
|
cols := []string{"asid","actor","targetUser","event","elementType","elementID"}
|
|
|
|
rows := `1,1,0,like,post,5
|
|
|
|
1,1,0,friend_invite,user,2`
|
|
|
|
return testdb.RowsFromCSVString(cols,rows), nil
|
|
|
|
})
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-02-28 09:27:28 +00:00
|
|
|
alert_handler.ServeHTTP(alert_w,alert_req)
|
|
|
|
fmt.Println(alert_w.Body)
|
|
|
|
if alert_w.Code != 200 {
|
|
|
|
panic("HTTP Error!")
|
|
|
|
}
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-02-28 09:27:28 +00:00
|
|
|
fmt.Println("No problems found in the alert handler!")
|
|
|
|
db = db_prod
|
|
|
|
}*/
|
|
|
|
|
2017-04-12 10:10:36 +00:00
|
|
|
func TestSplittyThing(t *testing.T) {
|
|
|
|
var extra_data string
|
|
|
|
var path string = "/pages/hohoho"
|
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
|
|
|
t.Log("Raw Path:",path)
|
2017-04-12 10:10:36 +00:00
|
|
|
if path[len(path) - 1] != '/' {
|
|
|
|
extra_data = path[strings.LastIndexByte(path,'/') + 1:]
|
|
|
|
path = path[:strings.LastIndexByte(path,'/') + 1]
|
|
|
|
}
|
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
|
|
|
t.Log("Path:", path)
|
|
|
|
t.Log("Extra Data:", extra_data)
|
|
|
|
t.Log("Path Bytes:", []byte(path))
|
|
|
|
t.Log("Extra Data Bytes:", []byte(extra_data))
|
2017-06-28 12:05:26 +00:00
|
|
|
|
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
|
|
|
t.Log("Splitty thing test")
|
2017-04-12 10:10:36 +00:00
|
|
|
path = "/topics/"
|
|
|
|
extra_data = ""
|
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
|
|
|
t.Log("Raw Path:",path)
|
2017-04-12 10:10:36 +00:00
|
|
|
if path[len(path) - 1] != '/' {
|
|
|
|
extra_data = path[strings.LastIndexByte(path,'/') + 1:]
|
|
|
|
path = path[:strings.LastIndexByte(path,'/') + 1]
|
|
|
|
}
|
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
|
|
|
t.Log("Path:", path)
|
|
|
|
t.Log("Extra Data:", extra_data)
|
|
|
|
t.Log("Path Bytes:", []byte(path))
|
|
|
|
t.Log("Extra Data Bytes:", []byte(extra_data))
|
2017-04-12 10:10:36 +00:00
|
|
|
}
|