Skip to content

Commit

Permalink
feat(identity): add tests (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
peknur authored Jul 14, 2023
1 parent f570bff commit 2f5fbd3
Showing 1 changed file with 69 additions and 0 deletions.
69 changes: 69 additions & 0 deletions internal/identity/identity_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package identity_test

import (
"context"
"testing"

"github.com/UpCloudLtd/upcloud-csi/internal/identity"
"github.com/UpCloudLtd/upcloud-csi/internal/logger"
"github.com/container-storage-interface/spec/lib/go/csi"
"github.com/stretchr/testify/require"
)

func TestIdentity_GetPluginInfo(t *testing.T) {
t.Parallel()

l := logger.New("error")
id := identity.NewIdentity("test", l.WithField("package", "identity_test"))
want := csi.GetPluginInfoResponse{
Name: "test",
}
got, err := id.GetPluginInfo(context.TODO(), nil)
require.NoError(t, err)
require.Equal(t, want, *got)
}

func TestIdentity_GetPluginCapabilities(t *testing.T) {
t.Parallel()

l := logger.New("error")
id := identity.NewIdentity("test", l.WithField("package", "identity_test"))
want := csi.GetPluginCapabilitiesResponse{
Capabilities: []*csi.PluginCapability{
{
Type: &csi.PluginCapability_Service_{
Service: &csi.PluginCapability_Service{
Type: csi.PluginCapability_Service_CONTROLLER_SERVICE,
},
},
},
{
Type: &csi.PluginCapability_Service_{
Service: &csi.PluginCapability_Service{
Type: csi.PluginCapability_Service_VOLUME_ACCESSIBILITY_CONSTRAINTS,
},
},
},
{
Type: &csi.PluginCapability_VolumeExpansion_{
VolumeExpansion: &csi.PluginCapability_VolumeExpansion{
Type: csi.PluginCapability_VolumeExpansion_OFFLINE,
},
},
},
},
}
got, err := id.GetPluginCapabilities(context.TODO(), nil)
require.NoError(t, err)
require.Equal(t, want, *got)
}

func TestIdentity_Probe(t *testing.T) {
t.Parallel()

l := logger.New("error")
id := identity.NewIdentity("test", l.WithField("package", "identity_test"))
got, err := id.Probe(context.TODO(), nil)
require.NoError(t, err)
require.True(t, got.Ready.Value)
}

0 comments on commit 2f5fbd3

Please sign in to comment.