MCPcopy Create free account
hub / github.com/alibaba/open-code-review / client

Function client

scripts/github-actions/check-pr-commit-policy.test.js:57–92  ·  view source on GitHub ↗
(pages, comparisons = [])

Source from the content-addressed store, hash-verified

55}
56
57function client(pages, comparisons = []) {
58 const calls = [];
59 const comparisonCalls = [];
60 return {
61 calls,
62 comparisonCalls,
63 rest: {
64 repos: {
65 async compareCommitsWithBasehead(options) {
66 comparisonCalls.push(options);
67 assert.strictEqual(options.owner, VARIABLES.owner);
68 assert.strictEqual(options.repo, VARIABLES.repo);
69 assert.strictEqual(options.per_page, 100);
70 assert.strictEqual(options.page, comparisonCalls.length);
71 assert.ok(comparisonCalls.length <= comparisons.length, "unexpected comparison call");
72 const data = comparisons[comparisonCalls.length - 1];
73 if (data instanceof Error) throw data;
74 return { data };
75 },
76 },
77 },
78 async graphql(query, variables) {
79 assert.ok(query.includes("commits(first: 100, after: $cursor)"));
80 assert.ok(!query.includes("body"));
81 assert.deepStrictEqual(
82 { owner: variables.owner, repo: variables.repo, number: variables.number },
83 VARIABLES
84 );
85 calls.push(variables);
86 assert.ok(calls.length <= pages.length, "unexpected API call");
87 const response = pages[calls.length - 1];
88 if (response instanceof Error) throw response;
89 return response;
90 },
91 };
92}
93
94function reporter() {
95 const messages = { errors: [], failures: [], info: [] };

Callers 2

CompletionsWithCtxMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected