Updated cgr-loader to accept URLs as path to data

This commit is contained in:
Trial97
2020-03-20 17:04:43 +02:00
committed by Dan Christian Bogos
parent d4fc68c86b
commit 57cfcbf5fc
7 changed files with 316 additions and 168 deletions

View File

@@ -942,3 +942,9 @@ type LoadIDsWithArgDispatcher struct {
TenantArg
*ArgDispatcher
}
// IsURL returns if the path is an URL
func IsURL(path string) bool {
return strings.HasPrefix(path, "https://") ||
strings.HasPrefix(path, "http://")
}

View File

@@ -1349,3 +1349,16 @@ func TestGetPathIndex(t *testing.T) {
t.Errorf("Expecting: nil, received: %+v", *index)
}
}
func TestIsURL(t *testing.T) {
urls := map[string]bool{
"/etc/usr/": false,
"https://github.com/cgrates/cgrates/": true,
"http://github.com/cgrates/cgrates/i": true,
}
for url, expected := range urls {
if rply := IsURL(url); rply != expected {
t.Errorf("For: %q ,expected %v received: %v", url, expected, rply)
}
}
}