add unit test

Signed-off-by: zhoumingcheng <zhoumingcheng@beyondcent.com>
This commit is contained in:
zhoumingcheng 2022-06-21 17:03:43 +08:00
parent 02462739ca
commit b722056698

View File

@ -180,3 +180,28 @@ func TestGetAddressAndDialer(t *testing.T) {
assert.Equal(t, test.expectedAddr, addr)
}
}
func TestLocalEndpoint(t *testing.T) {
tests := []struct {
path string
file string
expectError bool
expectedFullPath string
}{
{
path: "path",
file: "file",
expectError: false,
expectedFullPath: "unix:/path/file.sock",
},
}
for _, test := range tests {
fullPath, err := LocalEndpoint(test.path, test.file)
if test.expectError {
assert.NotNil(t, err, "expected error")
continue
}
assert.Nil(t, err, "expected no error")
assert.Equal(t, test.expectedFullPath, fullPath)
}
}