TestExistingConnection test sonarqube connection options @Summary test sonarqube connection @Description Test sonarqube Connection @Tags plugins/sonarqube @Param connectionId path int true "connection ID" @Success 200 {object} SonarqubeTestConnResponse "Success" @Failure 400 {string} errcode.Error
(input *plugin.ApiResourceInput)
| 113 | // @Failure 500 {string} errcode.Error "Internal Error" |
| 114 | // @Router /plugins/sonarqube/connections/{connectionId}/test [POST] |
| 115 | func TestExistingConnection(input *plugin.ApiResourceInput) (*plugin.ApiResourceOutput, errors.Error) { |
| 116 | connection, err := dsHelper.ConnApi.GetMergedConnection(input) |
| 117 | if err != nil { |
| 118 | return nil, errors.Convert(err) |
| 119 | } |
| 120 | // test connection |
| 121 | testConnectionResult, testConnectionErr := testConnection(context.TODO(), connection.SonarqubeConn) |
| 122 | if testConnectionErr != nil { |
| 123 | return nil, plugin.WrapTestConnectionErrResp(basicRes, testConnectionErr) |
| 124 | } |
| 125 | if testConnectionResult.Status != http.StatusOK { |
| 126 | errMsg := fmt.Sprintf("Test connection fail, unexpected status code: %d", testConnectionResult.Status) |
| 127 | return nil, plugin.WrapTestConnectionErrResp(basicRes, errors.Default.New(errMsg)) |
| 128 | } |
| 129 | return testConnectionResult, nil |
| 130 | } |
| 131 | |
| 132 | // PostConnections create sonarqube connection |
| 133 | // @Summary create sonarqube connection |
nothing calls this directly
no test coverage detected