MCPcopy Create free account
hub / github.com/devploit/nomore403 / TestReadURLsFromInput_FileInput

Function TestReadURLsFromInput_FileInput

cmd/output_test.go:18–36  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

16}
17
18func 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
38func TestReadURLsFromInput_NonExistentFile(t *testing.T) {
39 // A non-URL, non-file input should be returned as-is

Callers

nothing calls this directly

Calls 1

readURLsFromInputFunction · 0.85

Tested by

no test coverage detected