skillhub/github-sync-go/internal/github/request_control_test.go
XiaoSeS 2df4c913cb feat(github-sync): add continuous public repository discovery and skill sync
Signed-off-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com>
2026-10-20 14:40:46 +08:00

22 lines
923 B
Go

package github
import (
"context"
"errors"
"testing"
)
func TestPlatformControlFencesEveryGithubReadBeforeQuotaAndNetwork(t *testing.T) {
stop := errors.New("platform paused")
ctx := WithAcquisitionControl(context.Background(), func(context.Context) error { return stop })
client := NewClient("")
client.SetRequestPolicy(func(context.Context) error { t.Fatal("quota hook ran after platform stop"); return nil }, nil)
// All acquisition channels (search, owner listing, metadata, HEAD and Tree)
// pass through get; no external request may occur after the control denial.
for _, path := range []string{"/search/repositories", "/search/code", "/users/fixture/repos", "/repos/fixture/skills", "/repos/fixture/skills/git/ref/heads/main", "/repos/fixture/skills/git/trees/fixture"} {
var payload any
if _, err := client.get(ctx, path, &payload); !errors.Is(err, stop) {
t.Fatalf("%s: %v", path, err)
}
}
}