Skip to content

Commit

Permalink
use test response check uniformly for Nvme controller kvm
Browse files Browse the repository at this point in the history
Signed-off-by: Artsiom Koltun <[email protected]>
  • Loading branch information
artek-koltun authored and glimchb committed Jul 17, 2023
1 parent 320ad57 commit 5e9ca96
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions pkg/kvm/nvme_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
package kvm

import (
"bytes"
"context"
"log"
"os"
Expand Down Expand Up @@ -306,6 +305,11 @@ func TestCreateNvmeController(t *testing.T) {
request := server.ProtoClone(tt.in)

out, err := kvmServer.CreateNvmeController(context.Background(), request)

if !proto.Equal(out, tt.out) {
t.Error("response: expected", tt.out, "received", out)
}

if er, ok := status.FromError(err); ok {
if er.Code() != tt.errCode {
t.Error("error code: expected", tt.errCode, "received", er.Code())
Expand All @@ -317,11 +321,6 @@ func TestCreateNvmeController(t *testing.T) {
t.Errorf("expected grpc error status")
}

gotOut, _ := proto.Marshal(out)
wantOut, _ := proto.Marshal(tt.out)
if !bytes.Equal(gotOut, wantOut) {
t.Errorf("Expected out %v, got %v", tt.out, out)
}
if !qmpServer.WereExpectedCallsPerformed() {
t.Errorf("Not all expected calls were performed")
}
Expand Down

0 comments on commit 5e9ca96

Please sign in to comment.