mirror of
https://github.com/hanzoai/metrics.git
synced 2026-10-30 20:03:39 +00:00
Examples: 1) -metricsAuthKey=file:///abs/path/to/file - reads flag value from the given absolute filepath 2) -metricsAuthKey=file://./relative/path/to/file - reads flag value from the given relative filepath 3) -metricsAuthKey=http://some-host/some/path?query_arg=abc - reads flag value from the given url The flag value is automatically updated when the file contents changes.
21 lines
521 B
Go
21 lines
521 B
Go
package fscore
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestIsHTTPURL(t *testing.T) {
|
|
f := func(s string, expected bool) {
|
|
t.Helper()
|
|
res := isHTTPURL(s)
|
|
if res != expected {
|
|
t.Fatalf("expecting %t, got %t", expected, res)
|
|
}
|
|
}
|
|
f("http://isvalid:8000/filepath", true) // test http
|
|
f("https://isvalid:8000/filepath", true) // test https
|
|
f("tcp://notvalid:8000/filepath", false) // test tcp
|
|
f("0/filepath", false) // something invalid
|
|
f("filepath.extension", false) // something invalid
|
|
}
|