From 732dcd0479920e287e2616e5e67b2842d68d5d7e Mon Sep 17 00:00:00 2001 From: Pathe SENE Date: Tue, 3 Oct 2023 01:09:16 +0000 Subject: [PATCH] refactor: internal/helper/image_unit_test : add name to table tests --- .../internal/helper/image/image_unit_test.go | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/golang/internal/helper/image/image_unit_test.go b/golang/internal/helper/image/image_unit_test.go index 41ed3cb50..8894f9fe0 100644 --- a/golang/internal/helper/image/image_unit_test.go +++ b/golang/internal/helper/image/image_unit_test.go @@ -15,6 +15,7 @@ import ( ) type RegistryTestCase struct { + Name string Registry *string RegistryUrl *string ExpectedUrl string @@ -23,21 +24,25 @@ type RegistryTestCase struct { func TestRegistryWithTable(t *testing.T) { testCases := []RegistryTestCase{ { + Name: "Test registry url", Registry: pointer.NewPTR[string](""), RegistryUrl: pointer.NewPTR[string]("test"), ExpectedUrl: "test", }, { + Name: "Test registry url priority", Registry: pointer.NewPTR[string]("other"), RegistryUrl: pointer.NewPTR[string]("test"), ExpectedUrl: "test", }, { + Name: "Test registry url empty", Registry: nil, RegistryUrl: nil, ExpectedUrl: "", }, { + Name: "Test registry url registry", Registry: pointer.NewPTR[string]("other"), RegistryUrl: nil, ExpectedUrl: "other", @@ -45,14 +50,16 @@ func TestRegistryWithTable(t *testing.T) { } for _, tC := range testCases { - if tC.RegistryUrl == nil { - url := imageHelper.GetRegistryURL(tC.Registry, nil) - assert.Equal(t, url, tC.ExpectedUrl) - } else { - auth := &imageHelper.RegistryAuth{URL: *tC.RegistryUrl} - url := imageHelper.GetRegistryURL(tC.Registry, auth) - assert.Equal(t, url, tC.ExpectedUrl) - } + t.Run(tC.Name, func(t *testing.T) { + if tC.RegistryUrl == nil { + url := imageHelper.GetRegistryURL(tC.Registry, nil) + assert.Equal(t, url, tC.ExpectedUrl) + } else { + auth := &imageHelper.RegistryAuth{URL: *tC.RegistryUrl} + url := imageHelper.GetRegistryURL(tC.Registry, auth) + assert.Equal(t, url, tC.ExpectedUrl) + } + }) } }