Skip to content

Commit

Permalink
test(storage): add backend client tests
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 sandersms committed Jan 19, 2024
1 parent c3089eb commit 49ff5e7
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions storage/backend/client_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright (C) 2024 Intel Corporation

// Package backend implements the go library for OPI backend storage
package backend

import (
"testing"
)

func TestNewClient(t *testing.T) {
tests := map[string]struct {
address string
wantErr bool
wantClient bool
}{
"empty address": {
address: "",
wantErr: true,
wantClient: false,
},
"non-empty address": {
address: "localhost:50051",
wantErr: false,
wantClient: true,
},
}

for testName, tt := range tests {
t.Run(testName, func(t *testing.T) {
client, err := New(tt.address)
if (err != nil) == !tt.wantErr {
t.Errorf("expected err: %v, received: %v", tt.wantErr, err)
}
if (client != nil) == !tt.wantClient {
t.Errorf("expected client: %v, received: %v", tt.wantClient, client)
}
})
}
}

0 comments on commit 49ff5e7

Please sign in to comment.