Skip to content

Commit

Permalink
Provide more context for status code mismatch errors
Browse files Browse the repository at this point in the history
The default `Expect` error message when comparing gRPC status codes is
only somewhat useful on its own. Usually the message contains valuable
information to better debug the problem.

I only noticed this for a small subset of calls, but I figured it might
be useful for the whole file.
  • Loading branch information
avorima committed Apr 13, 2021
1 parent 6d79aac commit df74ae0
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions pkg/sanity/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ var _ = DescribeSanity("Node Service", func(sc *TestContext) {

serverError, ok := status.FromError(err)
Expect(ok).To(BeTrue())
Expect(serverError.Code()).To(Equal(codes.InvalidArgument))
Expect(serverError.Code()).To(Equal(codes.InvalidArgument), "unexpected error: %s", serverError.Message())
})

It("should fail when no target path is provided", func() {
Expand All @@ -402,7 +402,7 @@ var _ = DescribeSanity("Node Service", func(sc *TestContext) {

serverError, ok := status.FromError(err)
Expect(ok).To(BeTrue())
Expect(serverError.Code()).To(Equal(codes.InvalidArgument))
Expect(serverError.Code()).To(Equal(codes.InvalidArgument), "unexpected error: %s", serverError.Message())
})

It("should fail when no volume capability is provided", func() {
Expand All @@ -419,7 +419,7 @@ var _ = DescribeSanity("Node Service", func(sc *TestContext) {

serverError, ok := status.FromError(err)
Expect(ok).To(BeTrue())
Expect(serverError.Code()).To(Equal(codes.InvalidArgument))
Expect(serverError.Code()).To(Equal(codes.InvalidArgument), "unexpected error: %s", serverError.Message())
})
})

Expand All @@ -433,7 +433,7 @@ var _ = DescribeSanity("Node Service", func(sc *TestContext) {

serverError, ok := status.FromError(err)
Expect(ok).To(BeTrue())
Expect(serverError.Code()).To(Equal(codes.InvalidArgument))
Expect(serverError.Code()).To(Equal(codes.InvalidArgument), "unexpected error: %s", serverError.Message())
})

It("should fail when no target path is provided", func() {
Expand All @@ -447,7 +447,7 @@ var _ = DescribeSanity("Node Service", func(sc *TestContext) {

serverError, ok := status.FromError(err)
Expect(ok).To(BeTrue())
Expect(serverError.Code()).To(Equal(codes.InvalidArgument))
Expect(serverError.Code()).To(Equal(codes.InvalidArgument), "unexpected error: %s", serverError.Message())
})
})

Expand Down Expand Up @@ -480,7 +480,7 @@ var _ = DescribeSanity("Node Service", func(sc *TestContext) {

serverError, ok := status.FromError(err)
Expect(ok).To(BeTrue())
Expect(serverError.Code()).To(Equal(codes.InvalidArgument))
Expect(serverError.Code()).To(Equal(codes.InvalidArgument), "unexpected error: %s", serverError.Message())
})

It("should fail when no staging target path is provided", func() {
Expand All @@ -499,7 +499,7 @@ var _ = DescribeSanity("Node Service", func(sc *TestContext) {

serverError, ok := status.FromError(err)
Expect(ok).To(BeTrue())
Expect(serverError.Code()).To(Equal(codes.InvalidArgument))
Expect(serverError.Code()).To(Equal(codes.InvalidArgument), "unexpected error: %s", serverError.Message())
})

It("should fail when no volume capability is provided", func() {
Expand Down Expand Up @@ -542,7 +542,7 @@ var _ = DescribeSanity("Node Service", func(sc *TestContext) {

serverError, ok := status.FromError(err)
Expect(ok).To(BeTrue())
Expect(serverError.Code()).To(Equal(codes.InvalidArgument))
Expect(serverError.Code()).To(Equal(codes.InvalidArgument), "unexpected error: %s", serverError.Message())
})
})

Expand All @@ -564,7 +564,7 @@ var _ = DescribeSanity("Node Service", func(sc *TestContext) {

serverError, ok := status.FromError(err)
Expect(ok).To(BeTrue())
Expect(serverError.Code()).To(Equal(codes.InvalidArgument))
Expect(serverError.Code()).To(Equal(codes.InvalidArgument), "unexpected error: %s", serverError.Message())
})

It("should fail when no staging target path is provided", func() {
Expand All @@ -578,7 +578,7 @@ var _ = DescribeSanity("Node Service", func(sc *TestContext) {

serverError, ok := status.FromError(err)
Expect(ok).To(BeTrue())
Expect(serverError.Code()).To(Equal(codes.InvalidArgument))
Expect(serverError.Code()).To(Equal(codes.InvalidArgument), "unexpected error: %s", serverError.Message())
})
})

Expand All @@ -600,7 +600,7 @@ var _ = DescribeSanity("Node Service", func(sc *TestContext) {

serverError, ok := status.FromError(err)
Expect(ok).To(BeTrue())
Expect(serverError.Code()).To(Equal(codes.InvalidArgument))
Expect(serverError.Code()).To(Equal(codes.InvalidArgument), "unexpected error: %s", serverError.Message())
})

It("should fail when no volume path is provided", func() {
Expand All @@ -614,7 +614,7 @@ var _ = DescribeSanity("Node Service", func(sc *TestContext) {

serverError, ok := status.FromError(err)
Expect(ok).To(BeTrue())
Expect(serverError.Code()).To(Equal(codes.InvalidArgument))
Expect(serverError.Code()).To(Equal(codes.InvalidArgument), "unexpected error: %s", serverError.Message())
})

It("should fail when volume is not found", func() {
Expand All @@ -629,7 +629,7 @@ var _ = DescribeSanity("Node Service", func(sc *TestContext) {

serverError, ok := status.FromError(err)
Expect(ok).To(BeTrue())
Expect(serverError.Code()).To(Equal(codes.NotFound))
Expect(serverError.Code()).To(Equal(codes.NotFound), "unexpected error: %s", serverError.Message())
})

It("should fail when volume does not exist on the specified path", func() {
Expand Down Expand Up @@ -666,7 +666,7 @@ var _ = DescribeSanity("Node Service", func(sc *TestContext) {

serverError, ok := status.FromError(err)
Expect(ok).To(BeTrue())
Expect(serverError.Code()).To(Equal(codes.NotFound))
Expect(serverError.Code()).To(Equal(codes.NotFound), "unexpected error: %s", serverError.Message())
})

})
Expand All @@ -691,7 +691,7 @@ var _ = DescribeSanity("Node Service", func(sc *TestContext) {

serverError, ok := status.FromError(err)
Expect(ok).To(BeTrue())
Expect(serverError.Code()).To(Equal(codes.InvalidArgument))
Expect(serverError.Code()).To(Equal(codes.InvalidArgument), "unexpected error: %s", serverError.Message())
})

It("should fail when no volume path is provided", func() {
Expand All @@ -710,7 +710,7 @@ var _ = DescribeSanity("Node Service", func(sc *TestContext) {

serverError, ok := status.FromError(err)
Expect(ok).To(BeTrue())
Expect(serverError.Code()).To(Equal(codes.InvalidArgument))
Expect(serverError.Code()).To(Equal(codes.InvalidArgument), "unexpected error: %s", serverError.Message())
})

It("should fail when volume is not found", func() {
Expand All @@ -725,7 +725,7 @@ var _ = DescribeSanity("Node Service", func(sc *TestContext) {

serverError, ok := status.FromError(err)
Expect(ok).To(BeTrue())
Expect(serverError.Code()).To(Equal(codes.NotFound))
Expect(serverError.Code()).To(Equal(codes.NotFound), "unexpected error: %s", serverError.Message())
})

It("should work if node-expand is called after node-publish", func() {
Expand Down

0 comments on commit df74ae0

Please sign in to comment.