5376b9e271
* New config files As decided, config files are parsed at runtime. I decided to go for YAML config files because there can be comments in it. There are 2 files: * config/default_config.yml <= which shouldn't be edited unless we add a config parameter * config/config.yml <= which is the user-defined config. This file shouldn't be commited Changed every call to config.XXX to config.Conf.XXX (look to the new stucture of config in config/types.go) Of course, putting config parameters in config.yml overrides config in config_default.yml. You don't have to put everything in it, just add what you want to override. * Fixing test Replacing conf.New by config.Conf * Fixing call to config.Conf to config.Config{} in test files * Might have fixed testing with this Printf instead of Fatalf * Renaming config.yml in example file * Forbid commiting config.yml * Should be now fixed * Do not need this file anymore
21 lignes
467 o
Go
21 lignes
467 o
Go
package publicSettings
|
|
|
|
import (
|
|
"path"
|
|
"testing"
|
|
|
|
"github.com/NyaaPantsu/nyaa/config"
|
|
)
|
|
|
|
func TestInitI18n(t *testing.T) {
|
|
conf := config.I18nConfig{}
|
|
conf.Directory = "translations"
|
|
conf.DefaultLanguage = "en-us"
|
|
conf.Directory = path.Join("..", "..", conf.Directory)
|
|
var retriever UserRetriever // not required during initialization
|
|
|
|
err := InitI18n(conf, retriever)
|
|
if err != nil {
|
|
t.Errorf("failed to initialize language translations: %v", err)
|
|
}
|
|
}
|