diff options
Diffstat (limited to 'plugins/http/test/http_test.go')
-rw-r--r-- | plugins/http/test/http_test.go | 53 |
1 files changed, 51 insertions, 2 deletions
diff --git a/plugins/http/test/http_test.go b/plugins/http/test/http_test.go index c109d930..07925d33 100644 --- a/plugins/http/test/http_test.go +++ b/plugins/http/test/http_test.go @@ -1,10 +1,18 @@ package test import ( + "os" + "os/signal" + "syscall" "testing" + "time" "github.com/spiral/endure" "github.com/spiral/roadrunner/v2/plugins/config" + "github.com/spiral/roadrunner/v2/plugins/http" + "github.com/spiral/roadrunner/v2/plugins/logger" + //rpcPlugin "github.com/spiral/roadrunner/v2/plugins/rpc" + "github.com/spiral/roadrunner/v2/plugins/server" "github.com/stretchr/testify/assert" ) @@ -14,10 +22,51 @@ func TestHTTPInit(t *testing.T) { cfg := &config.Viper{ Path: ".rr-http.yaml", - Prefix: "", + Prefix: "rr", } + err = cont.RegisterAll( + cfg, + //&rpcPlugin.Plugin{}, + &logger.ZapLogger{}, + &server.Plugin{}, + &http.Plugin{}, + ) + assert.NoError(t, err) + + err = cont.Init() + if err != nil { + t.Fatal(err) + } - ) + ch, err := cont.Serve() assert.NoError(t, err) + + sig := make(chan os.Signal, 1) + signal.Notify(sig, os.Interrupt, syscall.SIGINT, syscall.SIGTERM) + + tt := time.NewTimer(time.Minute * 3) + for { + select { + case e := <-ch: + assert.Fail(t, "error", e.Error.Error()) + err = cont.Stop() + if err != nil { + assert.FailNow(t, "error", err.Error()) + } + case <-sig: + err = cont.Stop() + if err != nil { + assert.FailNow(t, "error", err.Error()) + } + return + case <-tt.C: + // timeout + err = cont.Stop() + if err != nil { + assert.FailNow(t, "error", err.Error()) + } + return + } + } } |