(t *testing.T)
| 78 | } |
| 79 | } |
| 80 | |
| 81 | func TestJavaScriptAdapterNormalizesResult(t *testing.T) { |
| 82 | client := &http.Client{Transport: roundTripFunc(func(request *http.Request) (*http.Response, error) { |
| 83 | if request.URL.String() != "https://example.test/feed" { |
| 84 | t.Fatalf("request URL = %q", request.URL) |
| 85 | } |
| 86 | return &http.Response{ |
| 87 | StatusCode: http.StatusOK, |
| 88 | Body: io.NopCloser(strings.NewReader(`["149.154.167.99/20"]`)), |
| 89 | Header: make(http.Header), |
| 90 | }, nil |
| 91 | })} |
| 92 | entries, err := (feedRunner{limits: testLimits(), client: client, timeout: time.Second}).run( |
| 93 | context.Background(), |
| 94 | store.Feed{ID: 1, Name: "test", URL: "https://example.test/feed"}, |
| 95 | store.FeedAdapter{ |
| 96 | APIVersion: 1, Source: ` |
| 97 | function sync(feed, api) { |
| 98 | return [{ |
| 99 | category: "Messengers", |
| 100 | service: "Telegram", |
| 101 | cidrs: JSON.parse(api.httpGet(feed.url)) |
| 102 | }]; |
| 103 | }`, |
| 104 | }, |
| 105 | ) |
| 106 | if err != nil { |
| 107 | t.Fatal(err) |
| 108 | } |
| 109 | if len(entries) != 1 || entries[0].CIDR != "149.154.160.0/20" { |
| 110 | t.Fatalf("entries = %#v", entries) |
| 111 | } |
| 112 | } |
| 113 | |
| 114 | func TestJavaScriptAdapterSRSGet(t *testing.T) { |
nothing calls this directly
no test coverage detected