MCPcopy Index your code
hub / github.com/google/go-github / TestRepositoriesService_GetAllRulesets

Function TestRepositoriesService_GetAllRulesets

github/repos_rules_test.go:253–319  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

251}
252
253func TestRepositoriesService_GetAllRulesets(t *testing.T) {
254 t.Parallel()
255 client, mux, _ := setup(t)
256
257 mux.HandleFunc("/repos/o/repo/rulesets", func(w http.ResponseWriter, r *http.Request) {
258 testMethod(t, r, "GET")
259 fmt.Fprintf(w, `[
260 {
261 "id": 42,
262 "name": "ruleset",
263 "source_type": "Repository",
264 "source": "o/repo",
265 "enforcement": "active",
266 "created_at": %[1]s,
267 "updated_at": %[1]s
268 },
269 {
270 "id": 314,
271 "name": "Another ruleset",
272 "source_type": "Repository",
273 "source": "o/repo",
274 "enforcement": "active",
275 "created_at": %[1]s,
276 "updated_at": %[1]s
277 }
278 ]`, referenceTimeStr)
279 })
280
281 ctx := t.Context()
282 ruleSet, _, err := client.Repositories.GetAllRulesets(ctx, "o", "repo", nil)
283 if err != nil {
284 t.Errorf("Repositories.GetAllRulesets returned error: %v", err)
285 }
286
287 want := []*RepositoryRuleset{
288 {
289 ID: Ptr(int64(42)),
290 Name: "ruleset",
291 SourceType: Ptr(RulesetSourceTypeRepository),
292 Source: "o/repo",
293 Enforcement: RulesetEnforcementActive,
294 CreatedAt: &Timestamp{referenceTime},
295 UpdatedAt: &Timestamp{referenceTime},
296 },
297 {
298 ID: Ptr(int64(314)),
299 Name: "Another ruleset",
300 SourceType: Ptr(RulesetSourceTypeRepository),
301 Source: "o/repo",
302 Enforcement: RulesetEnforcementActive,
303 CreatedAt: &Timestamp{referenceTime},
304 UpdatedAt: &Timestamp{referenceTime},
305 },
306 }
307 if !cmp.Equal(ruleSet, want) {
308 t.Errorf("Repositories.GetAllRulesets returned %+v, want %+v", ruleSet, want)
309 }
310

Callers

nothing calls this directly

Calls 6

testMethodFunction · 0.85
GetAllRulesetsMethod · 0.80
EqualMethod · 0.80
setupFunction · 0.70
PtrFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…