(t *testing.T)
| 778 | } |
| 779 | |
| 780 | func 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 | }, |
nothing calls this directly
no test coverage detected