From aa94b026ef15162d8151ae094b8af2550ccd1566 Mon Sep 17 00:00:00 2001 From: Tim Middleton Date: Mon, 12 Jun 2023 14:58:53 +0800 Subject: [PATCH] Minor code coverage updates --- coherence/session_test.go | 41 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/coherence/session_test.go b/coherence/session_test.go index 6c41173..dd6d2f6 100644 --- a/coherence/session_test.go +++ b/coherence/session_test.go @@ -35,3 +35,44 @@ func TestSessionValidation(t *testing.T) { g.Expect(err).To(gomega.Not(gomega.HaveOccurred())) g.Expect(s.sessOpts.Timeout).To(gomega.Equal(time.Duration(33) * time.Millisecond)) } + +func TestSessionEnvDebug(t *testing.T) { + var ( + g = gomega.NewWithT(t) + ctx = context.Background() + ) + t.Setenv(envSessionDebug, "true") + _, err := NewSession(ctx) + g.Expect(err).To(gomega.Not(gomega.HaveOccurred())) +} + +func TestConnectionOverride(t *testing.T) { + var ( + g = gomega.NewWithT(t) + ctx = context.Background() + ) + t.Setenv(envHostName, "localhost:12345") + s, err := NewSession(ctx) + g.Expect(err).To(gomega.Not(gomega.HaveOccurred())) + g.Expect(s.sessOpts.Address).To(gomega.Equal("localhost:12345")) +} + +func TestInvalidFormat(t *testing.T) { + var ( + g = gomega.NewWithT(t) + ctx = context.Background() + ) + _, err := NewSession(ctx, WithFormat("abc")) + g.Expect(err).To(gomega.HaveOccurred()) +} + +func TestSessionTimeout(t *testing.T) { + var ( + g = gomega.NewWithT(t) + ctx = context.Background() + ) + + t.Setenv(envSessionTimeout, "-1") + _, err := NewSession(ctx) + g.Expect(err).To(gomega.HaveOccurred()) +}