mirror of
https://github.com/SAP/jenkins-library.git
synced 2024-12-14 11:03:09 +02:00
fixed some codeclimate issues
This commit is contained in:
parent
c6f5dbf5ee
commit
1a609e5418
@ -75,7 +75,7 @@ func readContextDefaultDescription(contextDefaultPath string) map[string]string
|
||||
|
||||
// generates the step documentation and replaces the template with the generated documentation
|
||||
//func generateStepDocumentation(stepData config.StepData, docTemplateFilePath string, docTemplate io.ReadCloser, docFileWriter func(f string, d []byte, p os.FileMode) error) {
|
||||
func generateStepDocumentation(stepData config.StepData, docuHelperData DocuHelperData) error{
|
||||
func generateStepDocumentation(stepData config.StepData, docuHelperData DocuHelperData) error {
|
||||
|
||||
fmt.Printf("Generate docu for: %v\n", stepData.Metadata.Name)
|
||||
//create the file path for the template and open it.
|
||||
@ -85,13 +85,12 @@ func generateStepDocumentation(stepData config.StepData, docuHelperData DocuHelp
|
||||
|
||||
//check if there is an error during opening the template (true : skip docu generation for this meta data file)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error occured: %v\n", err)
|
||||
return fmt.Errorf("error occured: %v", err)
|
||||
}
|
||||
|
||||
content := readAndAdjustTemplate(docTemplate)
|
||||
if len(content) <= 0 {
|
||||
fmt.Printf("Error occured: No content inside of the template\n")
|
||||
return fmt.Errorf("Error occured: No content inside of the template\n")
|
||||
return fmt.Errorf("error occured: no content inside of the template")
|
||||
}
|
||||
|
||||
// binding of functions and placeholder
|
||||
|
@ -106,7 +106,7 @@ func TestGenerateStepDocumentationSuccess(t *testing.T) {
|
||||
contentMetaData, _ := configMetaDataMock("test.yaml")
|
||||
stepData.ReadPipelineStepData(contentMetaData)
|
||||
|
||||
generateStepDocumentation(stepData,DocuHelperData{true, "" ,configOpenDocTemplateFileMock , docFileWriterMock})
|
||||
generateStepDocumentation(stepData, DocuHelperData{true, "", configOpenDocTemplateFileMock, docFileWriterMock})
|
||||
|
||||
t.Run("Docu Generation Success", func(t *testing.T) {
|
||||
assert.Equal(t, expectedResultDocument, resultDocumentContent)
|
||||
@ -118,7 +118,7 @@ func TestGenerateStepDocumentationError(t *testing.T) {
|
||||
contentMetaData, _ := configMetaDataMock("test.yaml")
|
||||
stepData.ReadPipelineStepData(contentMetaData)
|
||||
|
||||
err := generateStepDocumentation(stepData, DocuHelperData{true, "Dummy" ,configOpenDocTemplateFileMock , docFileWriterMock})
|
||||
err := generateStepDocumentation(stepData, DocuHelperData{true, "Dummy", configOpenDocTemplateFileMock, docFileWriterMock})
|
||||
|
||||
t.Run("Docu Generation Success", func(t *testing.T) {
|
||||
assert.Error(t, err, fmt.Sprintf("Error occured: %v\n", err))
|
||||
|
@ -36,4 +36,3 @@ params:
|
||||
description: as dockerWorkspace for the sidecar container
|
||||
- name: stashContent
|
||||
description: Specific stashes that should be considered for the step execution.
|
||||
|
@ -53,7 +53,7 @@ func openDocTemplate(docTemplateFilePath string) (io.ReadCloser, error) {
|
||||
|
||||
//check if template exists otherwise print No Template found
|
||||
if _, err := os.Stat(docTemplateFilePath); os.IsNotExist(err) {
|
||||
err := fmt.Errorf("No Template found: %v \n", docTemplateFilePath)
|
||||
err := fmt.Errorf("no template found: %v", docTemplateFilePath)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user