summaryrefslogtreecommitdiff
path: root/tests/plugins/config/config_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'tests/plugins/config/config_test.go')
-rwxr-xr-xtests/plugins/config/config_test.go55
1 files changed, 55 insertions, 0 deletions
diff --git a/tests/plugins/config/config_test.go b/tests/plugins/config/config_test.go
index a0c2932b..79de2f59 100755
--- a/tests/plugins/config/config_test.go
+++ b/tests/plugins/config/config_test.go
@@ -215,3 +215,58 @@ func TestConfigEnvVariablesFail(t *testing.T) {
_, err = container.Serve()
assert.Error(t, err)
}
+
+func TestConfigProvider_GeneralSection(t *testing.T) {
+ container, err := endure.NewContainer(nil, endure.RetryOnFail(true), endure.SetLogLevel(endure.ErrorLevel))
+ if err != nil {
+ t.Fatal(err)
+ }
+ vp := &config.Viper{}
+ vp.Path = "configs/.rr.yaml"
+ vp.Prefix = "rr"
+ vp.Flags = nil
+ vp.CommonConfig = &config.General{GracefulTimeout: time.Second * 10}
+
+ err = container.Register(vp)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ err = container.Register(&Foo3{})
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ err = container.Init()
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ errCh, err := container.Serve()
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ // stop by CTRL+C
+ c := make(chan os.Signal, 1)
+ signal.Notify(c, os.Interrupt)
+
+ tt := time.NewTicker(time.Second * 2)
+ defer tt.Stop()
+
+ for {
+ select {
+ case e := <-errCh:
+ assert.NoError(t, e.Error)
+ assert.NoError(t, container.Stop())
+ return
+ case <-c:
+ er := container.Stop()
+ assert.NoError(t, er)
+ return
+ case <-tt.C:
+ assert.NoError(t, container.Stop())
+ return
+ }
+ }
+}