mirror of
https://github.com/SAP/jenkins-library.git
synced 2024-12-14 11:03:09 +02:00
fe72b295d6
* UpdateIntegrationArtifactConfiguration Command * Fixes for codeclimate Check * CommonStepsTest changes * CodeReview Changes * Git Patch * Git Patch undo * Code Review Comments * code review fixes * improve the error handling * codeclimate fixes * remove json parsing * Error handling changes * TestCase coverage fixes * Refactoring Commands * IntegrationArtifactDeploy Command * Regenerate metadata_generated * codereview fixes * Code Review Fixes * Code Review Fixes Co-authored-by: Oliver Nocon <33484802+OliverNocon@users.noreply.github.com> Co-authored-by: Oliver Feldmann <oliver.feldmann@sap.com>
48 lines
1.1 KiB
Go
48 lines
1.1 KiB
Go
// +build !release
|
|
|
|
package cpi
|
|
|
|
import (
|
|
"bytes"
|
|
"io/ioutil"
|
|
"net/http"
|
|
|
|
"github.com/pkg/errors"
|
|
)
|
|
|
|
//GetCPIFunctionMockResponse -Generate mock response payload for different CPI functions
|
|
func GetCPIFunctionMockResponse(functionName, testType string) (*http.Response, error) {
|
|
switch functionName {
|
|
case "IntegrationArtifactDeploy":
|
|
if testType == "Positive" {
|
|
return GetEmptyHTTPResponseBody()
|
|
}
|
|
res := http.Response{
|
|
StatusCode: 500,
|
|
Body: ioutil.NopCloser(bytes.NewReader([]byte(`{
|
|
"code": "Internal Server Error",
|
|
"message": {
|
|
"@lang": "en",
|
|
"#text": "Cannot deploy artifact with Id 'flow1'!"
|
|
}
|
|
}`))),
|
|
}
|
|
return &res, errors.New("Internal Server Error")
|
|
default:
|
|
res := http.Response{
|
|
StatusCode: 404,
|
|
Body: ioutil.NopCloser(bytes.NewReader([]byte(``))),
|
|
}
|
|
return &res, errors.New("Service not Found")
|
|
}
|
|
}
|
|
|
|
//GetEmptyHTTPResponseBody -Empty http respose body
|
|
func GetEmptyHTTPResponseBody() (*http.Response, error) {
|
|
res := http.Response{
|
|
StatusCode: 202,
|
|
Body: ioutil.NopCloser(bytes.NewReader([]byte(``))),
|
|
}
|
|
return &res, nil
|
|
}
|