(t *testing.T)
| 35 | } |
| 36 | |
| 37 | func Test_ProjectsList_ListProjects(t *testing.T) { |
| 38 | toolDef := ProjectsList(translations.NullTranslationHelper) |
| 39 | |
| 40 | orgProjects := []map[string]any{{"id": 1, "node_id": "NODE1", "title": "Org Project"}} |
| 41 | userProjects := []map[string]any{{"id": 2, "node_id": "NODE2", "title": "User Project"}} |
| 42 | |
| 43 | tests := []struct { |
| 44 | name string |
| 45 | mockedClient *http.Client |
| 46 | requestArgs map[string]any |
| 47 | expectError bool |
| 48 | expectedErrMsg string |
| 49 | expectedLength int |
| 50 | }{ |
| 51 | { |
| 52 | name: "success organization", |
| 53 | mockedClient: MockHTTPClientWithHandlers(map[string]http.HandlerFunc{ |
| 54 | GetOrgsProjectsV2: mockResponse(t, http.StatusOK, orgProjects), |
| 55 | }), |
| 56 | requestArgs: map[string]any{ |
| 57 | "method": "list_projects", |
| 58 | "owner": "octo-org", |
| 59 | "owner_type": "org", |
| 60 | }, |
| 61 | expectError: false, |
| 62 | expectedLength: 1, |
| 63 | }, |
| 64 | { |
| 65 | name: "success user", |
| 66 | mockedClient: MockHTTPClientWithHandlers(map[string]http.HandlerFunc{ |
| 67 | GetUsersProjectsV2ByUsername: mockResponse(t, http.StatusOK, userProjects), |
| 68 | }), |
| 69 | requestArgs: map[string]any{ |
| 70 | "method": "list_projects", |
| 71 | "owner": "octocat", |
| 72 | "owner_type": "user", |
| 73 | }, |
| 74 | expectError: false, |
| 75 | expectedLength: 1, |
| 76 | }, |
| 77 | { |
| 78 | name: "missing required parameter method", |
| 79 | mockedClient: MockHTTPClientWithHandlers(map[string]http.HandlerFunc{}), |
| 80 | requestArgs: map[string]any{ |
| 81 | "owner": "octo-org", |
| 82 | "owner_type": "org", |
| 83 | }, |
| 84 | expectError: true, |
| 85 | expectedErrMsg: "missing required parameter: method", |
| 86 | }, |
| 87 | { |
| 88 | name: "unknown method", |
| 89 | mockedClient: MockHTTPClientWithHandlers(map[string]http.HandlerFunc{}), |
| 90 | requestArgs: map[string]any{ |
| 91 | "method": "unknown_method", |
| 92 | "owner": "octo-org", |
| 93 | "owner_type": "org", |
| 94 | }, |
nothing calls this directly
no test coverage detected