From 1d325a53028e7eb714001f945d41f206b7a90c60 Mon Sep 17 00:00:00 2001 From: rafalw82 <150019998+rafalw82@users.noreply.github.com> Date: Tue, 18 Feb 2025 12:37:21 +0100 Subject: [PATCH] [ISSUE-658] identity UT (#1266) Signed-off-by: Rafal Wegrzyn --- pkg/controller/identity_test.go | 49 +++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 pkg/controller/identity_test.go diff --git a/pkg/controller/identity_test.go b/pkg/controller/identity_test.go new file mode 100644 index 000000000..8f8681c8a --- /dev/null +++ b/pkg/controller/identity_test.go @@ -0,0 +1,49 @@ +package controller + +import ( + "context" + "testing" + + "github.com/container-storage-interface/spec/lib/go/csi" + "github.com/stretchr/testify/assert" +) + +func Test_GetPluginInfo(t *testing.T) { + t.Run("Test GetPluginInfo", func(t *testing.T) { + ctx := context.Background() + + defaultIdentityServer := NewIdentityServer("Test", "1.0.0") + response, err := defaultIdentityServer.GetPluginInfo(ctx, nil) + assert.Nil(t, err) + + assert.Equal(t, response.Name, "Test") + assert.Equal(t, response.VendorVersion, "1.0.0") + }) +} + +func Test_GetPluginCapabilities(t *testing.T) { + t.Run("Test GetPluginCapabilities", func(t *testing.T) { + ctx := context.Background() + + defaultIdentityServer := NewIdentityServer("Test", "1.0.0") + response, err := defaultIdentityServer.GetPluginCapabilities(ctx, nil) + assert.Nil(t, err) + + assert.Equal(t, response.Capabilities[0].GetService().Type, csi.PluginCapability_Service_CONTROLLER_SERVICE) + assert.Equal(t, response.Capabilities[1].GetService().Type, csi.PluginCapability_Service_VOLUME_ACCESSIBILITY_CONSTRAINTS) + assert.Equal(t, response.Capabilities[2].GetVolumeExpansion().Type, csi.PluginCapability_VolumeExpansion_ONLINE) + assert.Equal(t, response.Capabilities[3].GetVolumeExpansion().Type, csi.PluginCapability_VolumeExpansion_OFFLINE) + }) +} + +func Test_Probe(t *testing.T) { + t.Run("Test Probe", func(t *testing.T) { + ctx := context.Background() + + defaultIdentityServer := NewIdentityServer("Test", "1.0.0") + response, err := defaultIdentityServer.Probe(ctx, nil) + assert.Nil(t, err) + + assert.True(t, response.Ready.Value) + }) +}