MCPcopy Index your code
hub / github.com/cli/cli / TestFetchRepoVisibility

Function TestFetchRepoVisibility

internal/skills/discovery/discovery_test.go:780–858  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

778}
779
780func TestFetchRepoVisibility(t *testing.T) {
781 tests := []struct {
782 name string
783 stubs func(*httpmock.Registry)
784 want RepoVisibility
785 wantErr string
786 }{
787 {
788 name: "public repo",
789 stubs: func(reg *httpmock.Registry) {
790 reg.Register(
791 httpmock.REST("GET", "repos/monalisa/octocat-skills"),
792 httpmock.JSONResponse(map[string]interface{}{
793 "visibility": "public",
794 }))
795 },
796 want: RepoVisibilityPublic,
797 },
798 {
799 name: "private repo",
800 stubs: func(reg *httpmock.Registry) {
801 reg.Register(
802 httpmock.REST("GET", "repos/monalisa/octocat-skills"),
803 httpmock.JSONResponse(map[string]interface{}{
804 "visibility": "private",
805 }))
806 },
807 want: RepoVisibilityPrivate,
808 },
809 {
810 name: "internal repo",
811 stubs: func(reg *httpmock.Registry) {
812 reg.Register(
813 httpmock.REST("GET", "repos/monalisa/octocat-skills"),
814 httpmock.JSONResponse(map[string]interface{}{
815 "visibility": "internal",
816 }))
817 },
818 want: RepoVisibilityInternal,
819 },
820 {
821 name: "unknown visibility",
822 stubs: func(reg *httpmock.Registry) {
823 reg.Register(
824 httpmock.REST("GET", "repos/monalisa/octocat-skills"),
825 httpmock.JSONResponse(map[string]interface{}{
826 "visibility": "cool-visibility",
827 }))
828 },
829 wantErr: `unknown repository visibility: "cool-visibility"`,
830 },
831 {
832 name: "API error",
833 stubs: func(reg *httpmock.Registry) {
834 reg.Register(
835 httpmock.REST("GET", "repos/monalisa/octocat-skills"),
836 httpmock.StatusStringResponse(500, "server error"))
837 },

Callers

nothing calls this directly

Calls 11

RegisterMethod · 0.95
VerifyMethod · 0.95
RESTFunction · 0.92
JSONResponseFunction · 0.92
StatusStringResponseFunction · 0.92
NewClientFromHTTPFunction · 0.92
FetchRepoVisibilityFunction · 0.85
ContainsMethod · 0.80
EqualMethod · 0.80
RunMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected