mirror of
https://github.com/LukeHagar/slinky.git
synced 2025-12-06 04:21:20 +00:00
43 lines
1.1 KiB
Go
43 lines
1.1 KiB
Go
package fsurls
|
|
|
|
import (
|
|
"path/filepath"
|
|
"testing"
|
|
)
|
|
|
|
func TestCollectURLs_FromCodeFiles(t *testing.T) {
|
|
root := filepath.Join("..", "..", "testdata")
|
|
urls, err := CollectURLs(root, []string{"**/*"})
|
|
if err != nil {
|
|
t.Fatalf("CollectURLs error: %v", err)
|
|
}
|
|
|
|
// Valid URLs from various languages should be present (including a known nonexistent-but-well-formed)
|
|
valids := []string{
|
|
"https://example.com",
|
|
"https://en.wikipedia.org/wiki/Main_Page",
|
|
"https://developer.mozilla.org",
|
|
"https://svelte.dev",
|
|
"https://go.dev/doc/",
|
|
"https://this-domain-does-not-exist-123456789.com",
|
|
}
|
|
for _, u := range valids {
|
|
if _, ok := urls[u]; !ok {
|
|
t.Fatalf("expected valid URL %q to be collected", u)
|
|
}
|
|
}
|
|
|
|
// Placeholder patterns should be excluded by strict validation
|
|
placeholders := []string{
|
|
"https://[tenant].api.identitynow.com",
|
|
"https://{tenant}.api.identitynow.com",
|
|
"https://[tenant].[domain].com",
|
|
"https://{tenant}.api.ideidentitynow.com/v3/transforms",
|
|
}
|
|
for _, u := range placeholders {
|
|
if _, ok := urls[u]; ok {
|
|
t.Fatalf("did not expect placeholder URL %q to be collected", u)
|
|
}
|
|
}
|
|
}
|