@@ -48,3 +48,87 @@ func TestOrganizationsService_ListOutsideCollaborators_invalidOrg(t *testing.T)
4848 _ , _ , err := client .Organizations .ListOutsideCollaborators (context .Background (), "%" , nil )
4949 testURLParseError (t , err )
5050}
51+
52+ func TestOrganizationsService_RemoveOutsideCollaborator (t * testing.T ) {
53+ client , mux , _ , teardown := setup ()
54+ defer teardown ()
55+
56+ handler := func (w http.ResponseWriter , r * http.Request ) {
57+ testMethod (t , r , "DELETE" )
58+ }
59+ mux .HandleFunc ("/orgs/o/outside_collaborators/u" , handler )
60+
61+ _ , err := client .Organizations .RemoveOutsideCollaborator (context .Background (), "o" , "u" )
62+ if err != nil {
63+ t .Errorf ("Organizations.RemoveOutsideCollaborator returned error: %v" , err )
64+ }
65+ }
66+
67+ func TestOrganizationsService_RemoveOutsideCollaborator_NonMember (t * testing.T ) {
68+ client , mux , _ , teardown := setup ()
69+ defer teardown ()
70+
71+ handler := func (w http.ResponseWriter , r * http.Request ) {
72+ testMethod (t , r , "DELETE" )
73+ w .WriteHeader (http .StatusNotFound )
74+ }
75+ mux .HandleFunc ("/orgs/o/outside_collaborators/u" , handler )
76+
77+ _ , err := client .Organizations .RemoveOutsideCollaborator (context .Background (), "o" , "u" )
78+ if err , ok := err .(* ErrorResponse ); ! ok {
79+ t .Errorf ("Organizations.RemoveOutsideCollaborator did not return an error" )
80+ } else if err .Response .StatusCode != http .StatusNotFound {
81+ t .Errorf ("Organizations.RemoveOutsideCollaborator did not return 404 status code" )
82+ }
83+ }
84+
85+ func TestOrganizationsService_RemoveOutsideCollaborator_Member (t * testing.T ) {
86+ client , mux , _ , teardown := setup ()
87+ defer teardown ()
88+
89+ handler := func (w http.ResponseWriter , r * http.Request ) {
90+ testMethod (t , r , "DELETE" )
91+ w .WriteHeader (http .StatusUnprocessableEntity )
92+ }
93+ mux .HandleFunc ("/orgs/o/outside_collaborators/u" , handler )
94+
95+ _ , err := client .Organizations .RemoveOutsideCollaborator (context .Background (), "o" , "u" )
96+ if err , ok := err .(* ErrorResponse ); ! ok {
97+ t .Errorf ("Organizations.RemoveOutsideCollaborator did not return an error" )
98+ } else if err .Response .StatusCode != http .StatusUnprocessableEntity {
99+ t .Errorf ("Organizations.RemoveOutsideCollaborator did not return 422 status code" )
100+ }
101+ }
102+
103+ func TestOrganizationsService_ConvertMemberToOutsideCollaborator (t * testing.T ) {
104+ client , mux , _ , teardown := setup ()
105+ defer teardown ()
106+
107+ handler := func (w http.ResponseWriter , r * http.Request ) {
108+ testMethod (t , r , "PUT" )
109+ }
110+ mux .HandleFunc ("/orgs/o/outside_collaborators/u" , handler )
111+
112+ _ , err := client .Organizations .ConvertMemberToOutsideCollaborator (context .Background (), "o" , "u" )
113+ if err != nil {
114+ t .Errorf ("Organizations.ConvertMemberToOutsideCollaborator returned error: %v" , err )
115+ }
116+ }
117+
118+ func TestOrganizationsService_ConvertMemberToOutsideCollaborator_NonMemberOrLastOwner (t * testing.T ) {
119+ client , mux , _ , teardown := setup ()
120+ defer teardown ()
121+
122+ handler := func (w http.ResponseWriter , r * http.Request ) {
123+ testMethod (t , r , "PUT" )
124+ w .WriteHeader (http .StatusForbidden )
125+ }
126+ mux .HandleFunc ("/orgs/o/outside_collaborators/u" , handler )
127+
128+ _ , err := client .Organizations .ConvertMemberToOutsideCollaborator (context .Background (), "o" , "u" )
129+ if err , ok := err .(* ErrorResponse ); ! ok {
130+ t .Errorf ("Organizations.ConvertMemberToOutsideCollaborator did not return an error" )
131+ } else if err .Response .StatusCode != http .StatusForbidden {
132+ t .Errorf ("Organizations.ConvertMemberToOutsideCollaborator did not return 403 status code" )
133+ }
134+ }
0 commit comments