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

Function TestPackageVersion_GetBody

github/packages_test.go:448–502  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

446}
447
448func TestPackageVersion_GetBody(t *testing.T) {
449 t.Parallel()
450
451 tests := map[string]struct {
452 pv *PackageVersion
453 wantValue string
454 wantOk bool
455 }{
456 "pv nil": {
457 pv: nil,
458 wantValue: "",
459 wantOk: false,
460 },
461 "body nil": {
462 pv: &PackageVersion{
463 Body: nil,
464 },
465 wantValue: "",
466 wantOk: false,
467 },
468 "invalid body": {
469 pv: &PackageVersion{
470 Body: json.RawMessage(`{
471 "repository": {
472 "name": "n"
473 },
474 "info": {
475 "type": "t"
476 }
477 }`),
478 },
479 wantValue: "",
480 wantOk: false,
481 },
482 "valid body": {
483 pv: &PackageVersion{
484 Body: json.RawMessage(`"body"`),
485 },
486 wantValue: "body",
487 wantOk: true,
488 },
489 }
490
491 for name, test := range tests {
492 t.Run(name, func(t *testing.T) {
493 t.Parallel()
494
495 resValue, resOk := test.pv.GetBody()
496
497 if resValue != test.wantValue || resOk != test.wantOk {
498 t.Errorf("PackageVersion.GetBody() - got: %v, %v; want: %v, %v", resValue, resOk, test.wantValue, test.wantOk)
499 }
500 })
501 }
502}
503
504func TestPackageVersion_GetBodyAsPackageVersionBody(t *testing.T) {
505 t.Parallel()

Callers

nothing calls this directly

Calls 2

RunMethod · 0.45
GetBodyMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…