コード例 #1
0
func main() {
	ctx := pwreset.ParseArgs()
	log := pwreset.CreateLogger(ctx)

	// start the service...
	log.Info("start services with context: ", ctx.ToMap())

	err := pwreset.StartServers(ctx)

	if err != nil {
		fmt.Println("error starting servers: ", err)
		panic(err)
	}
}
コード例 #2
0
func TestContext(t *testing.T) {
	g := Goblin(t)

	g.Describe("Context", func() {
		pwreset.CreateLogger(pwreset.NewContextForEnvironment("test"))

		g.It("should create a context struct", func() {
			ctx := new(pwreset.Context)

			g.Assert(ctx.GetShutdownPort()).Equal(0)
		})

		g.It("should create a context struct with defaults set", func() {
			ctx := pwreset.NewDefaultContext()

			g.Assert(ctx.GetShutdownPort()).Equal(3019)

			hash := ctx.ToMap()

			g.Assert(hash != nil)

			if value, ok := hash["webroot"]; ok {
				g.Assert(value).Equal("public")
			}

			g.Assert(hash["baseport"]).Equal(3011)
			g.Assert(hash["shutdownPort"]).Equal(3019)
			g.Assert(hash["serverCount"]).Equal(1)
			g.Assert(hash["timeout"]).Equal(int64(600))
		})

		g.It("should create context from args", func() {
			ctx := pwreset.ParseArgs()

			g.Assert(ctx.GetShutdownPort()).Equal(3019)

			hash := ctx.ToMap()

			g.Assert(hash["baseport"]).Equal(3011)
			g.Assert(hash["shutdownPort"]).Equal(3019)
			g.Assert(hash["serverCount"]).Equal(1)
			g.Assert(hash["timeout"]).Equal(int64(600))
		})

	})
}