Fix LogURI generation-related tests on Windows.
Signed-off-by: Nashwan Azhari <nazhari@cloudbasesolutions.com>
This commit is contained in:
@@ -81,46 +81,27 @@ func TestLogFileFailOnRelativePath(t *testing.T) {
|
||||
assert.Error(t, err, "absolute path needed")
|
||||
}
|
||||
|
||||
func TestLogURIGenerator(t *testing.T) {
|
||||
for _, tc := range []struct {
|
||||
scheme string
|
||||
path string
|
||||
args map[string]string
|
||||
expected string
|
||||
err string
|
||||
}{
|
||||
{
|
||||
scheme: "fifo",
|
||||
path: "/full/path/pipe.fifo",
|
||||
expected: "fifo:///full/path/pipe.fifo",
|
||||
},
|
||||
{
|
||||
scheme: "file",
|
||||
path: "/full/path/file.txt",
|
||||
args: map[string]string{
|
||||
"maxSize": "100MB",
|
||||
},
|
||||
expected: "file:///full/path/file.txt?maxSize=100MB",
|
||||
},
|
||||
{
|
||||
scheme: "binary",
|
||||
path: "/full/path/bin",
|
||||
args: map[string]string{
|
||||
"id": "testing",
|
||||
},
|
||||
expected: "binary:///full/path/bin?id=testing",
|
||||
},
|
||||
{
|
||||
scheme: "unknown",
|
||||
path: "nowhere",
|
||||
err: "absolute path needed",
|
||||
},
|
||||
} {
|
||||
type LogURIGeneratorTestCase struct {
|
||||
// Arbitrary scheme string (e.g. "binary")
|
||||
scheme string
|
||||
// Path to executable/file: (e.g. "/some/path/to/bin.exe")
|
||||
path string
|
||||
// Extra query args expected to be in the URL (e.g. "id=123")
|
||||
args map[string]string
|
||||
// What the test case is expecting as an output (e.g. "binary:///some/path/to/bin.exe?id=123")
|
||||
expected string
|
||||
// Error string to be expected:
|
||||
err string
|
||||
}
|
||||
|
||||
func baseTestLogURIGenerator(t *testing.T, testCases []LogURIGeneratorTestCase) {
|
||||
for _, tc := range testCases {
|
||||
uri, err := LogURIGenerator(tc.scheme, tc.path, tc.args)
|
||||
if err != nil {
|
||||
assert.Error(t, err, tc.err)
|
||||
if tc.err != "" {
|
||||
assert.ErrorContains(t, err, tc.err)
|
||||
continue
|
||||
}
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, tc.expected, uri.String())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user