feat(backend): implement task creation and admin web
This commit is contained in:
@@ -18,6 +18,9 @@ func TestLoadUsesSafeDefaults(t *testing.T) {
|
||||
if cfg.DatabasePath != filepath.FromSlash("var/cmroubao.db") {
|
||||
t.Fatalf("DatabasePath = %q", cfg.DatabasePath)
|
||||
}
|
||||
if cfg.AssetDirectory != filepath.FromSlash("var/assets") {
|
||||
t.Fatalf("AssetDirectory = %q", cfg.AssetDirectory)
|
||||
}
|
||||
if cfg.ReadHeaderTimeout <= 0 ||
|
||||
cfg.ReadTimeout <= 0 ||
|
||||
cfg.WriteTimeout <= 0 ||
|
||||
@@ -33,8 +36,9 @@ func TestLoadUsesSafeDefaults(t *testing.T) {
|
||||
|
||||
func TestLoadAcceptsExplicitConfiguration(t *testing.T) {
|
||||
values := map[string]string{
|
||||
HTTPAddressEnvironment: "192.0.2.10:9090",
|
||||
DatabasePathEnvironment: "tmp/test.db",
|
||||
HTTPAddressEnvironment: "192.0.2.10:9090",
|
||||
DatabasePathEnvironment: "tmp/test.db",
|
||||
AssetDirectoryEnvironment: "tmp/assets",
|
||||
}
|
||||
|
||||
cfg, err := Load(mapEnvironment(values))
|
||||
@@ -48,6 +52,9 @@ func TestLoadAcceptsExplicitConfiguration(t *testing.T) {
|
||||
if cfg.DatabasePath != filepath.Clean(values[DatabasePathEnvironment]) {
|
||||
t.Fatalf("DatabasePath = %q", cfg.DatabasePath)
|
||||
}
|
||||
if cfg.AssetDirectory != filepath.Clean(values[AssetDirectoryEnvironment]) {
|
||||
t.Fatalf("AssetDirectory = %q", cfg.AssetDirectory)
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadRejectsUnsafeOrInvalidValues(t *testing.T) {
|
||||
@@ -97,6 +104,18 @@ func TestLoadRejectsUnsafeOrInvalidValues(t *testing.T) {
|
||||
DatabasePathEnvironment: "var/database.txt",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "asset root directory",
|
||||
values: map[string]string{
|
||||
AssetDirectoryEnvironment: string(filepath.Separator),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "asset current directory",
|
||||
values: map[string]string{
|
||||
AssetDirectoryEnvironment: ".",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
|
||||
Reference in New Issue
Block a user