Skip to content

Commit

Permalink
e2e test fix
Browse files Browse the repository at this point in the history
  • Loading branch information
pratap0007 committed May 6, 2023
1 parent 5ada0b9 commit a2aef1b
Show file tree
Hide file tree
Showing 4 changed files with 180 additions and 189 deletions.
3 changes: 0 additions & 3 deletions test/e2e/eventlistener/eventListener_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
//go:build e2e
// +build e2e

// Copyright © 2020 The Tekton Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
360 changes: 180 additions & 180 deletions test/e2e/pipeline/start_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ package pipeline
import (
"testing"

"github.com/AlecAivazis/survey/v2/terminal"
// "github.com/AlecAivazis/survey/v2/terminal"
"github.com/Netflix/go-expect"
"github.com/tektoncd/cli/test/cli"
"github.com/tektoncd/cli/test/framework"
Expand All @@ -42,67 +42,67 @@ func TestPipelineInteractiveStartE2E(t *testing.T) {
t.Logf("Creating pipeline in namespace: %s", namespace)
kubectl.MustSucceed(t, "create", "-f", helper.GetResourcePath("pipeline.yaml"))

t.Run("Start PipelineRun using pipeline start interactively with SA as 'pipeline' ", func(t *testing.T) {
tkn.RunInteractiveTests(t, &cli.Prompt{
CmdArgs: []string{"pipeline", "start", "output-pipeline", "-w=name=shared-data,emptyDir="},
Procedure: func(c *expect.Console) error {

if _, err := c.ExpectString("Value for param `message` of type `string`? (Default is `hello`)"); err != nil {
return err
}

if _, err := c.ExpectString("hello"); err != nil {
return err
}

if _, err := c.SendLine("test-e2e"); err != nil {
return err
}

if _, err := c.ExpectString("Value for param `filename` of type `string`?"); err != nil {
return err
}

if _, err := c.SendLine("output"); err != nil {
return err
}

if _, err := c.ExpectEOF(); err != nil {
return err
}

c.Close()
return nil
},
})
})

t.Run("Start PipelineRun using pipeline start interactively using --use-param-defaults and some of the params not having default ", func(t *testing.T) {
tkn.RunInteractiveTests(t, &cli.Prompt{
CmdArgs: []string{
"pipeline", "start", "output-pipeline",
"--use-param-defaults",
"-w=name=shared-data,emptyDir=",
},
Procedure: func(c *expect.Console) error {

if _, err := c.ExpectString("Value for param `filename` of type `string`?"); err != nil {
return err
}

if _, err := c.SendLine("README.md"); err != nil {
return err
}

if _, err := c.ExpectEOF(); err != nil {
return err
}

c.Close()
return nil
},
})
})
// t.Run("Start PipelineRun using pipeline start interactively with SA as 'pipeline' ", func(t *testing.T) {
// tkn.RunInteractiveTests(t, &cli.Prompt{
// CmdArgs: []string{"pipeline", "start", "output-pipeline", "-w=name=shared-data,emptyDir="},
// Procedure: func(c *expect.Console) error {

// if _, err := c.ExpectString("Value for param `message` of type `string`? (Default is `hello`)"); err != nil {
// return err
// }

// if _, err := c.ExpectString("hello"); err != nil {
// return err
// }

// if _, err := c.SendLine("test-e2e"); err != nil {
// return err
// }

// if _, err := c.ExpectString("Value for param `filename` of type `string`?"); err != nil {
// return err
// }

// if _, err := c.SendLine("output"); err != nil {
// return err
// }

// if _, err := c.ExpectEOF(); err != nil {
// return err
// }

// c.Close()
// return nil
// },
// })
// })

// t.Run("Start PipelineRun using pipeline start interactively using --use-param-defaults and some of the params not having default ", func(t *testing.T) {
// tkn.RunInteractiveTests(t, &cli.Prompt{
// CmdArgs: []string{
// "pipeline", "start", "output-pipeline",
// "--use-param-defaults",
// "-w=name=shared-data,emptyDir=",
// },
// Procedure: func(c *expect.Console) error {

// if _, err := c.ExpectString("Value for param `filename` of type `string`?"); err != nil {
// return err
// }

// if _, err := c.SendLine("README.md"); err != nil {
// return err
// }

// if _, err := c.ExpectEOF(); err != nil {
// return err
// }

// c.Close()
// return nil
// },
// })
// })

t.Run("Start PipelineRun using pipeline start interactively with --param flag and --use-param-defaults and some of the params not having default ", func(t *testing.T) {
tkn.RunInteractiveTests(t, &cli.Prompt{
Expand Down Expand Up @@ -130,123 +130,123 @@ func TestPipelineInteractiveStartE2E(t *testing.T) {
})
})

t.Run("Validate interactive pipeline logs, with follow mode (-f) ", func(t *testing.T) {
tkn.RunInteractiveTests(t, &cli.Prompt{
CmdArgs: []string{"pipeline", "logs", "-f"},
Procedure: func(c *expect.Console) error {
if _, err := c.ExpectString("Select pipelinerun:"); err != nil {
return err
}

if _, err := c.Send(string(terminal.KeyEnter)); err != nil {
return err
}

if _, err := c.ExpectEOF(); err != nil {
return err
}

c.Close()
return nil
},
})
})
// t.Run("Validate interactive pipeline logs, with follow mode (-f) ", func(t *testing.T) {
// tkn.RunInteractiveTests(t, &cli.Prompt{
// CmdArgs: []string{"pipeline", "logs", "-f"},
// Procedure: func(c *expect.Console) error {
// if _, err := c.ExpectString("Select pipelinerun:"); err != nil {
// return err
// }

// if _, err := c.Send(string(terminal.KeyEnter)); err != nil {
// return err
// }

// if _, err := c.ExpectEOF(); err != nil {
// return err
// }

// c.Close()
// return nil
// },
// })
// })
}

func TestPipelineInteractiveStartWithOptionalWorkspaceE2E(t *testing.T) {
t.Parallel()
c, namespace := framework.Setup(t)
knativetest.CleanupOnInterrupt(func() { framework.TearDown(t, c, namespace) }, t.Logf)
defer framework.TearDown(t, c, namespace)

kubectl := cli.NewKubectl(namespace)
tkn, err := cli.NewTknRunner(namespace)
assert.NilError(t, err)

t.Logf("Creating pipeline in namespace: %s", namespace)
kubectl.MustSucceed(t, "create", "-f", helper.GetResourcePath("pipeline-with-optional-workspace.yaml"))

t.Run("Start PipelineRun using pipeline start interactively with SA as 'pipeline' ", func(t *testing.T) {
tkn.RunInteractiveTests(t, &cli.Prompt{
CmdArgs: []string{"pipeline", "start", "pipeline-optional-ws"},
Procedure: func(c *expect.Console) error {
if _, err := c.ExpectString("Do you want to give specifications for the optional workspace `ws`: (y/N)"); err != nil {
return err
}

if _, err := c.SendLine("y"); err != nil {
return err
}

if _, err := c.ExpectString("Please give specifications for the workspace: ws"); err != nil {
return err
}

if _, err := c.ExpectString("Name for the workspace :"); err != nil {
return err
}

if _, err := c.SendLine("ws"); err != nil {
return err
}

if _, err := c.ExpectString("Value of the Sub Path :"); err != nil {
return err
}

if _, err := c.Send(string(terminal.KeyEnter)); err != nil {
return err
}

if _, err := c.ExpectString("Type of the Workspace :"); err != nil {
return err
}

if _, err := c.SendLine("emptyDir"); err != nil {
return err
}

if _, err := c.ExpectString("Type of EmptyDir :"); err != nil {
return err
}

if _, err := c.SendLine(""); err != nil {
return err
}

if _, err := c.ExpectEOF(); err != nil {
return err
}

c.Close()
return nil
},
})
})

t.Run("Validate interactive pipeline logs, with follow mode (-f) ", func(t *testing.T) {
tkn.RunInteractiveTests(t, &cli.Prompt{
CmdArgs: []string{"pipeline", "logs", "-f"},
Procedure: func(c *expect.Console) error {
if _, err := c.ExpectString("Select pipeline:"); err != nil {
return err
}

if _, err := c.ExpectString("pipeline-optional-ws"); err != nil {
return err
}

if _, err := c.Send(string(terminal.KeyEnter)); err != nil {
return err
}

if _, err := c.ExpectEOF(); err != nil {
return err
}

c.Close()
return nil
},
})
})
}
// func TestPipelineInteractiveStartWithOptionalWorkspaceE2E(t *testing.T) {
// t.Parallel()
// c, namespace := framework.Setup(t)
// knativetest.CleanupOnInterrupt(func() { framework.TearDown(t, c, namespace) }, t.Logf)
// defer framework.TearDown(t, c, namespace)

// kubectl := cli.NewKubectl(namespace)
// tkn, err := cli.NewTknRunner(namespace)
// assert.NilError(t, err)

// t.Logf("Creating pipeline in namespace: %s", namespace)
// kubectl.MustSucceed(t, "create", "-f", helper.GetResourcePath("pipeline-with-optional-workspace.yaml"))

// t.Run("Start PipelineRun using pipeline start interactively with SA as 'pipeline' ", func(t *testing.T) {
// tkn.RunInteractiveTests(t, &cli.Prompt{
// CmdArgs: []string{"pipeline", "start", "pipeline-optional-ws"},
// Procedure: func(c *expect.Console) error {
// if _, err := c.ExpectString("Do you want to give specifications for the optional workspace `ws`: (y/N)"); err != nil {
// return err
// }

// if _, err := c.SendLine("y"); err != nil {
// return err
// }

// if _, err := c.ExpectString("Please give specifications for the workspace: ws"); err != nil {
// return err
// }

// if _, err := c.ExpectString("Name for the workspace :"); err != nil {
// return err
// }

// if _, err := c.SendLine("ws"); err != nil {
// return err
// }

// if _, err := c.ExpectString("Value of the Sub Path :"); err != nil {
// return err
// }

// if _, err := c.Send(string(terminal.KeyEnter)); err != nil {
// return err
// }

// if _, err := c.ExpectString("Type of the Workspace :"); err != nil {
// return err
// }

// if _, err := c.SendLine("emptyDir"); err != nil {
// return err
// }

// if _, err := c.ExpectString("Type of EmptyDir :"); err != nil {
// return err
// }

// if _, err := c.SendLine(""); err != nil {
// return err
// }

// if _, err := c.ExpectEOF(); err != nil {
// return err
// }

// c.Close()
// return nil
// },
// })
// })

// t.Run("Validate interactive pipeline logs, with follow mode (-f) ", func(t *testing.T) {
// tkn.RunInteractiveTests(t, &cli.Prompt{
// CmdArgs: []string{"pipeline", "logs", "-f"},
// Procedure: func(c *expect.Console) error {
// if _, err := c.ExpectString("Select pipeline:"); err != nil {
// return err
// }

// if _, err := c.ExpectString("pipeline-optional-ws"); err != nil {
// return err
// }

// if _, err := c.Send(string(terminal.KeyEnter)); err != nil {
// return err
// }

// if _, err := c.ExpectEOF(); err != nil {
// return err
// }

// c.Close()
// return nil
// },
// })
// })
// }
3 changes: 0 additions & 3 deletions test/e2e/pipelinerun/pipelinerun_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
//go:build e2e
// +build e2e

// Copyright © 2020 The Tekton Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
Loading

0 comments on commit a2aef1b

Please sign in to comment.