mirror of
https://github.com/webinstall/webi-installers.git
synced 2026-04-07 02:46:50 +00:00
nodedist: generic fetcher for any Node.js-style dist index.json API. Returns raw API entries with no transformation or normalization. Uses iter.Seq2 for a paginated interface consistent across sources. node: calls nodedist twice — official builds and unofficial builds (musl, loong64, etc.) — yielding one batch per source.
37 lines
735 B
Go
37 lines
735 B
Go
package node_test
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
"testing"
|
|
|
|
"github.com/webinstall/webi-installers/internal/releases/node"
|
|
)
|
|
|
|
func TestFetchCombinesSources(t *testing.T) {
|
|
if testing.Short() {
|
|
t.Skip("skipping network test in short mode")
|
|
}
|
|
|
|
ctx := context.Background()
|
|
client := &http.Client{}
|
|
|
|
var batches int
|
|
var total int
|
|
for entries, err := range node.Fetch(ctx, client) {
|
|
if err != nil {
|
|
t.Fatalf("batch %d: %v", batches, err)
|
|
}
|
|
batches++
|
|
total += len(entries)
|
|
}
|
|
|
|
if batches != 2 {
|
|
t.Errorf("got %d batches, want 2 (official + unofficial)", batches)
|
|
}
|
|
if total < 100 {
|
|
t.Errorf("got %d total entries, expected at least 100", total)
|
|
}
|
|
t.Logf("fetched %d entries in %d batches", total, batches)
|
|
}
|