mirror of
https://github.com/redhat-developer/odo.git
synced 2025-10-19 03:06:19 +03:00
Downloading wrong starter project when using odo init (#6346)
* fix: downloading wrong starter project when using odo init in interactive mode Signed-off-by: anandrkskd <anandrkskd@gmail.com> * test: odo init downloads correct devfile-starter Signed-off-by: anandrkskd <anandrkskd@gmail.com> Signed-off-by: anandrkskd <anandrkskd@gmail.com>
This commit is contained in:
committed by
GitHub
parent
ab273dcac6
commit
c9875200ed
@@ -53,7 +53,6 @@ func (o *Survey) AskType(types registry.TypesWithDetails) (back bool, _ api.Devf
|
||||
}
|
||||
|
||||
func (o *Survey) AskStarterProject(projects []string) (bool, int, error) {
|
||||
sort.Strings(projects)
|
||||
projects = append(projects, "** NO STARTER PROJECT **")
|
||||
question := &survey.Select{
|
||||
Message: "Which starter project do you want to use?",
|
||||
|
||||
@@ -95,6 +95,11 @@ func (o *InteractiveBackend) SelectStarterProject(devfile parser.DevfileObj, fla
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
sort.Slice(starterProjects, func(i, j int) bool {
|
||||
return starterProjects[i].Name < starterProjects[j].Name
|
||||
})
|
||||
|
||||
names := make([]string, 0, len(starterProjects))
|
||||
for _, starterProject := range starterProjects {
|
||||
names = append(names, starterProject.Name)
|
||||
|
||||
@@ -159,6 +159,35 @@ var _ = Describe("odo init interactive command tests", Label(helper.LabelNoClust
|
||||
Expect(helper.ListFilesInDir(commonVar.Context)).To(ContainElements("devfile.yaml"))
|
||||
})
|
||||
|
||||
It("should download correct devfile-starter", func() {
|
||||
|
||||
command := []string{"odo", "init"}
|
||||
output, err := helper.RunInteractive(command, nil, func(ctx helper.InteractiveContext) {
|
||||
|
||||
By("showing the interactive mode notice message", func() {
|
||||
helper.ExpectString(ctx, messages.InteractiveModeEnabled)
|
||||
})
|
||||
|
||||
helper.ExpectString(ctx, "Select language")
|
||||
helper.SendLine(ctx, "java")
|
||||
|
||||
helper.ExpectString(ctx, "Select project type")
|
||||
helper.SendLine(ctx, "Vert.x Java")
|
||||
|
||||
helper.ExpectString(ctx, "Which starter project do you want to use")
|
||||
helper.SendLine(ctx, "vertx-cache-example-redhat")
|
||||
|
||||
helper.ExpectString(ctx, "Enter component name")
|
||||
helper.SendLine(ctx, "my-app")
|
||||
|
||||
helper.ExpectString(ctx, "Your new component 'my-app' is ready in the current directory")
|
||||
|
||||
})
|
||||
|
||||
Expect(err).To(BeNil())
|
||||
Expect(output).To(ContainSubstring("Downloading starter project \"vertx-cache-example-redhat\""))
|
||||
})
|
||||
|
||||
Describe("displaying welcoming messages", func() {
|
||||
|
||||
// testFunc is a function that returns a `Tester` function (intended to be used via `helper.RunInteractive`),
|
||||
|
||||
Reference in New Issue
Block a user