package logging

import (
	"github.com/UpmeshLTD/urus-aio/infrastructure/config"
	. "github.com/onsi/ginkgo/v2"
	. "github.com/onsi/gomega"
)

var _ = Describe("config", Ordered, func() {
	var (
		cp config.Provider
	)

	BeforeEach(func() {
		cp = config.NewProvider()
	})

	When("init", func() {
		It("should load", func() {
			conf := GetConfig(cp)

			Expect(conf.Level).Should(Equal("debug"))
			Expect(conf.IsDevelopment).Should(BeTrue())
		})

		Context("with custom section name", func() {
			BeforeEach(func() {
				ConfigSectionName = "log_config"
			})

			It("should load", func() {
				conf := GetConfig(cp)

				Expect(conf.Level).Should(Equal("debug"))
				Expect(conf.IsDevelopment).Should(BeTrue())
			})
		})
	})
})
