-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix the problem of rendering choice parameter incorrectly (#371)
* Bump Jenkins client Signed-off-by: John Niang <[email protected]> * Simplify type of parametere definition Signed-off-by: John Niang <[email protected]> * Bump jenkins-zh/jenins-client to v0.0.6 Signed-off-by: John Niang <[email protected]> * Reuse ParameterTypeMap Signed-off-by: John Niang <[email protected]>
- Loading branch information
Showing
5 changed files
with
156 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
138 changes: 138 additions & 0 deletions
138
controllers/jenkins/pipeline/metadata_converter_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
package pipeline | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
|
||
"github.com/jenkins-zh/jenkins-client/pkg/job" | ||
) | ||
|
||
func Test_convertParameterDefinitions(t *testing.T) { | ||
type args struct { | ||
paramDefs []job.ParameterDefinition | ||
} | ||
tests := []struct { | ||
name string | ||
args args | ||
want []job.ParameterDefinition | ||
}{{ | ||
name: "Convert nil parameter definitions", | ||
args: args{}, | ||
want: []job.ParameterDefinition{}, | ||
}, { | ||
name: "Convert empty parameter definitions", | ||
args: args{ | ||
paramDefs: []job.ParameterDefinition{}, | ||
}, | ||
want: []job.ParameterDefinition{}, | ||
}, { | ||
name: "Convert string parameter definition", | ||
args: args{ | ||
paramDefs: []job.ParameterDefinition{{ | ||
Name: "string-name", | ||
Type: "StringParameterDefinition", | ||
}}, | ||
}, | ||
want: []job.ParameterDefinition{{ | ||
Name: "string-name", | ||
Type: "string", | ||
}}, | ||
}, { | ||
name: "Convert choice parameter definition", | ||
args: args{ | ||
paramDefs: []job.ParameterDefinition{{ | ||
Name: "choice-name", | ||
Type: "ChoiceParameterDefinition", | ||
}}, | ||
}, | ||
want: []job.ParameterDefinition{{ | ||
Name: "choice-name", | ||
Type: "choice", | ||
}}, | ||
}, { | ||
name: "Convert text parameter definition", | ||
args: args{ | ||
paramDefs: []job.ParameterDefinition{{ | ||
Name: "text-name", | ||
Type: "TextParameterDefinition", | ||
}}, | ||
}, | ||
want: []job.ParameterDefinition{{ | ||
Name: "text-name", | ||
Type: "text", | ||
}}, | ||
}, { | ||
name: "Convert boolean parameter definition", | ||
args: args{ | ||
paramDefs: []job.ParameterDefinition{{ | ||
Name: "boolean-name", | ||
Type: "BooleanParameterDefinition", | ||
}}, | ||
}, | ||
want: []job.ParameterDefinition{{ | ||
Name: "boolean-name", | ||
Type: "boolean", | ||
}}, | ||
}, { | ||
name: "Convert file parameter definition", | ||
args: args{ | ||
paramDefs: []job.ParameterDefinition{{ | ||
Name: "file-name", | ||
Type: "FileParameterDefinition", | ||
}}, | ||
}, | ||
want: []job.ParameterDefinition{{ | ||
Name: "file-name", | ||
Type: "file", | ||
}}, | ||
}, { | ||
name: "Convert password parameter definition", | ||
args: args{ | ||
paramDefs: []job.ParameterDefinition{{ | ||
Name: "password-name", | ||
Type: "PasswordParameterDefinition", | ||
}}, | ||
}, | ||
want: []job.ParameterDefinition{{ | ||
Name: "password-name", | ||
Type: "password", | ||
}}, | ||
}, { | ||
name: "Convert multi parameter definitions", | ||
args: args{ | ||
paramDefs: []job.ParameterDefinition{{ | ||
Name: "password-name", | ||
Type: "PasswordParameterDefinition", | ||
}, { | ||
Name: "file-name", | ||
Type: "FileParameterDefinition", | ||
}}, | ||
}, | ||
want: []job.ParameterDefinition{{ | ||
Name: "password-name", | ||
Type: "password", | ||
}, { | ||
Name: "file-name", | ||
Type: "file", | ||
}}, | ||
}, { | ||
name: "Convert invalid parameter definition", | ||
args: args{ | ||
paramDefs: []job.ParameterDefinition{{ | ||
Name: "invalid-name", | ||
Type: "InvalidParameterDefinition", | ||
}}, | ||
}, | ||
want: []job.ParameterDefinition{{ | ||
Name: "invalid-name", | ||
Type: "InvalidParameterDefinition", | ||
}}, | ||
}} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
if got := convertParameterDefinitions(tt.args.paramDefs); !reflect.DeepEqual(got, tt.want) { | ||
t.Errorf("convertParameterDefinitions() = %v, want %v", got, tt.want) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters