Skip to content

Commit

Permalink
add UT's for prompts
Browse files Browse the repository at this point in the history
  • Loading branch information
hsubramanianaks committed Jun 8, 2023
1 parent 6c0d174 commit 597106e
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions pkg/prompts/prompts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,60 @@ func TestGetVariableDefaultValue(t *testing.T) {
}
}

func TestGetDetectedDefaultValue(t *testing.T) {
tests := []struct {
testName string
variableName string
detectedDefaults []config.BuilderVarDefault
inputs map[string]string
want string
}{
{
testName: "basicTest",
variableName: "VERSION",
detectedDefaults: []config.BuilderVarDefault{
{
Name: "VERSION",
Value: "jre11",
},
{
Name: "BUILDERVERSION",
Value: "jdk8",
},
},
inputs: map[string]string{},
want: "jre11",
},
{
testName: "testWithoutDetectedDefaults",
variableName: "VERSION",
detectedDefaults: []config.BuilderVarDefault{},
inputs: map[string]string{},
want: "",
},
{
testName: "testWithBuilderVersion",
variableName: "BUILDERVERSION",
detectedDefaults: []config.BuilderVarDefault{
{
Name: "BUILDERVERSION",
Value: "jdk8",
ReferenceVar: "",
},
},
inputs: map[string]string{},
want: "jdk8",
},
}
for _, tt := range tests {
t.Run(tt.testName, func(t *testing.T) {
if got := GetDetectedDefaultValue(tt.variableName, tt.detectedDefaults, tt.inputs); got != tt.want {
t.Errorf("GetDetectedDefaultValue() = %v, want %v", got, tt.want)
}
})
}
}

func TestRunStringPrompt(t *testing.T) {
tests := []struct {
testName string
Expand Down

0 comments on commit 597106e

Please sign in to comment.