(t *testing.T)
| 16 | } |
| 17 | |
| 18 | func TestReadURLsFromInput_FileInput(t *testing.T) { |
| 19 | dir := t.TempDir() |
| 20 | filePath := filepath.Join(dir, "urls.txt") |
| 21 | content := "https://example.com/admin\nhttps://example.com/secret\n# comment\n\nhttps://example.com/api\n" |
| 22 | if err := os.WriteFile(filePath, []byte(content), 0o600); err != nil { |
| 23 | t.Fatalf("write file: %v", err) |
| 24 | } |
| 25 | |
| 26 | urls := readURLsFromInput(filePath) |
| 27 | if len(urls) != 3 { |
| 28 | t.Fatalf("expected 3 URLs, got %d: %v", len(urls), urls) |
| 29 | } |
| 30 | if urls[0] != "https://example.com/admin" { |
| 31 | t.Errorf("url[0] = %q, want https://example.com/admin", urls[0]) |
| 32 | } |
| 33 | if urls[2] != "https://example.com/api" { |
| 34 | t.Errorf("url[2] = %q, want https://example.com/api", urls[2]) |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | func TestReadURLsFromInput_NonExistentFile(t *testing.T) { |
| 39 | // A non-URL, non-file input should be returned as-is |
nothing calls this directly
no test coverage detected