From 8578b4000dbfd4f60dbf028f945a446b2f961f3b Mon Sep 17 00:00:00 2001 From: danish siddiqui Date: Wed, 27 Mar 2024 17:30:21 +0530 Subject: [PATCH] fixed tests Signed-off-by: danish siddiqui --- pkg/provisioner/ironic/factory_test.go | 31 ++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/pkg/provisioner/ironic/factory_test.go b/pkg/provisioner/ironic/factory_test.go index 7422936865..d23ba8b75c 100644 --- a/pkg/provisioner/ironic/factory_test.go +++ b/pkg/provisioner/ironic/factory_test.go @@ -180,7 +180,38 @@ func TestLoadConfigFromEnv(t *testing.T) { } } } +func TestLoadEndpointsFromEnv(t *testing.T) { + cases := []struct { + name string + env EnvFixture + expectError bool + }{ + { + name: "with-ironic", + env: EnvFixture{ + ironicEndpoint: "http://ironic.test", + }, + }, { + name: "without-ironic", + env: EnvFixture{}, + expectError: true, + }, + } + for _, tc := range cases { + t.Run(tc.name, func(t *testing.T) { + defer tc.env.TearDown() + tc.env.SetUp() + i, err := loadEndpointsFromEnv() + if tc.expectError { + assert.NotNil(t, err) + } else { + assert.Nil(t, err) + tc.env.VerifyEndpoints(t, i) + } + }) + } +} func TestLoadTLSConfigFromEnv(t *testing.T) { const ( TLSKeyFilePath = "/opt/metal3/certs/client/tls.key"