-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(storage): add backend client tests
Signed-off-by: Artsiom Koltun <[email protected]>
- Loading branch information
1 parent
c3089eb
commit 49ff5e7
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
}) | ||
} | ||
} |