| 14 | ) |
| 15 | |
| 16 | func TestIsURL(t *testing.T) { |
| 17 | tests := []struct { |
| 18 | path string |
| 19 | want bool |
| 20 | }{ |
| 21 | {"http://example.com/config.yaml", true}, |
| 22 | {"https://example.com/config.yaml", true}, |
| 23 | {"HTTP://EXAMPLE.COM/config.yaml", false}, // case-sensitive |
| 24 | {"/etc/config.yaml", false}, |
| 25 | {"config.yaml", false}, |
| 26 | {"", false}, |
| 27 | {"ftp://example.com/config.yaml", false}, |
| 28 | } |
| 29 | for _, tt := range tests { |
| 30 | t.Run(tt.path, func(t *testing.T) { |
| 31 | assert.Equal(t, tt.want, isURL(tt.path)) |
| 32 | }) |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | func newTestHTTPProvider(t *testing.T, url string, client *http.Client) (*httpProvider, *prometheus.Registry) { |
| 37 | reg := prometheus.NewPedanticRegistry() |