From 6945646cd749029255715339ecee01baf0a2d64f Mon Sep 17 00:00:00 2001 From: Caj Larsson Date: Mon, 25 Apr 2022 00:32:35 +0800 Subject: [PATCH] Configuration test --- application/configuration_test.go | 43 +++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 application/configuration_test.go 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") + } +}