Skip to content

Commit

Permalink
Merge pull request #68 from thiagodasilva/new_identity_tests
Browse files Browse the repository at this point in the history
Added Identity Probe and GetPluginCapabilities tests
  • Loading branch information
lpabon authored May 2, 2018
2 parents 134de10 + 4842570 commit 57aeb5f
Showing 1 changed file with 54 additions and 2 deletions.
56 changes: 54 additions & 2 deletions pkg/sanity/identity.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,70 @@ limitations under the License.
package sanity

import (
"fmt"
"regexp"

"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"

csi "github.com/container-storage-interface/spec/lib/go/csi/v0"
context "golang.org/x/net/context"

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)

// TODO: Tests for GetPluginCapabilities
var _ = Describe("GetPluginCapabilities [Identity Service]", func() {
var (
c csi.IdentityClient
)

BeforeEach(func() {
c = csi.NewIdentityClient(conn)
})

It("should return appropriate capabilities", func() {
req := &csi.GetPluginCapabilitiesRequest{}
res, err := c.GetPluginCapabilities(context.Background(), req)
Expect(err).NotTo(HaveOccurred())
Expect(res).NotTo(BeNil())

By("checking successful response")
Expect(res.GetCapabilities()).NotTo(BeNil())
for _, cap := range res.GetCapabilities() {
switch cap.GetService().GetType() {
case csi.PluginCapability_Service_CONTROLLER_SERVICE:
default:
Fail(fmt.Sprintf("Unknown capability: %v\n", cap.GetService().GetType()))
}
}

})

})

var _ = Describe("Probe [Identity Service]", func() {
var (
c csi.IdentityClient
)

// TODO: Tests for Probe
BeforeEach(func() {
c = csi.NewIdentityClient(conn)
})

It("should return appropriate information", func() {
req := &csi.ProbeRequest{}
res, err := c.Probe(context.Background(), req)
Expect(err).NotTo(HaveOccurred())
Expect(res).NotTo(BeNil())

By("verifying return status")
serverError, ok := status.FromError(err)
Expect(ok).To(BeTrue())
Expect(serverError.Code() == codes.FailedPrecondition ||
serverError.Code() == codes.OK).To(BeTrue())
})
})

var _ = Describe("GetPluginInfo [Identity Server]", func() {
var (
Expand Down

0 comments on commit 57aeb5f

Please sign in to comment.