diff --git a/application/configuration_test.go b/application/configuration_test.go new file mode 100644 index 0000000..923a086 --- /dev/null +++ b/application/configuration_test.go @@ -0,0 +1,43 @@ +package application + + +import ( + "time" + "testing" +) + + +func TestConfiguration(t *testing.T) { + c, _ := ConfigFromToml( +`[server] + port = 8002 + host = "127.0.0.1" + +[file] + path = "/tmp/datta2" + +[database] + backend = "sqlite" + connection = "sql.db" + +[quota] + default_size = "1MB" + default_duration = "72h"`, + ) + + if c.Server.Port != 8002 { + t.Errorf("port parsing failed") + } + + if c.Server.Host != "127.0.0.1" { + t.Errorf("host parsing failed") + } + + if c.Quota.ParsedSizeBytes() != 1024 * 1024 { + t.Errorf("quota size parsing failed") + } + + if c.Quota.ParsedDuration() != time.Duration(time.Hour * 72) { + t.Errorf("quota size parsing failed") + } +}