Skip to content

Commit

Permalink
chore: fix unit test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
shaheerkootteeri committed Oct 13, 2023
1 parent 6736138 commit 4dd7eec
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
24 changes: 12 additions & 12 deletions pkg/commands/workload_apply_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ status:
{
Name: "create - output yaml with wait",
Args: []string{workloadName, flags.GitRepoFlagName, gitRepo, flags.GitBranchFlagName, gitBranch,
flags.OutputFlagName, printer.OutputFormatYaml, flags.WaitFlagName, flags.YesFlagName, flags.DelayTimeFlagName, "0ms"},
flags.OutputFlagName, printer.OutputFormatYaml, flags.WaitFlagName, flags.YesFlagName, flags.DelayTimeFlagName, "0ns"},
GivenObjects: givenNamespaceDefault,
Prepare: func(t *testing.T, ctx context.Context, config *cli.Config, tc *clitesting.CommandTestCase) (context.Context, error) {
workload := &cartov1alpha1.Workload{
Expand Down Expand Up @@ -936,7 +936,7 @@ To get status: "tanzu apps workload get my-workload"
{
Name: "wait with timeout error",
Skip: runtm.GOOS == "windows",
Args: []string{workloadName, flags.GitRepoFlagName, gitRepo, flags.GitBranchFlagName, gitBranch, flags.YesFlagName, flags.WaitFlagName, flags.WaitTimeoutFlagName, "1ns"},
Args: []string{workloadName, flags.GitRepoFlagName, gitRepo, flags.GitBranchFlagName, gitBranch, flags.YesFlagName, flags.WaitFlagName, flags.WaitTimeoutFlagName, "1ns", flags.DelayTimeFlagName, "0ns"},
Prepare: func(t *testing.T, ctx context.Context, config *cli.Config, tc *clitesting.CommandTestCase) (context.Context, error) {
workload := &cartov1alpha1.Workload{
ObjectMeta: metav1.ObjectMeta{
Expand Down Expand Up @@ -1011,7 +1011,7 @@ Error waiting for ready condition: timeout after 1ns waiting for "my-workload" t
},
{
Name: "create - successful wait for ready cond",
Args: []string{workloadName, flags.GitRepoFlagName, gitRepo, flags.GitBranchFlagName, gitBranch, flags.YesFlagName, flags.WaitFlagName},
Args: []string{workloadName, flags.GitRepoFlagName, gitRepo, flags.GitBranchFlagName, gitBranch, flags.YesFlagName, flags.WaitFlagName, flags.DelayTimeFlagName, "0ns"},
Prepare: func(t *testing.T, ctx context.Context, config *cli.Config, tc *clitesting.CommandTestCase) (context.Context, error) {
workload := &cartov1alpha1.Workload{
ObjectMeta: metav1.ObjectMeta{
Expand Down Expand Up @@ -1203,7 +1203,7 @@ Workload "my-workload" is ready
},
{
Name: "create - watcher error",
Args: []string{workloadName, flags.GitRepoFlagName, gitRepo, flags.GitBranchFlagName, gitBranch, flags.YesFlagName, flags.WaitFlagName},
Args: []string{workloadName, flags.GitRepoFlagName, gitRepo, flags.GitBranchFlagName, gitBranch, flags.YesFlagName, flags.WaitFlagName, flags.DelayTimeFlagName, "0ns"},
Prepare: func(t *testing.T, ctx context.Context, config *cli.Config, tc *clitesting.CommandTestCase) (context.Context, error) {
fakewatch := watchfakes.NewFakeWithWatch(true, config.Client, []watch.Event{})
ctx = watchhelper.WithWatcher(ctx, fakewatch)
Expand Down Expand Up @@ -1990,7 +1990,7 @@ Error: conflict updating workload, the object was modified by another user; plea
{
Name: "update - wait for ready condition - error with timeout",
Skip: runtm.GOOS == "windows",
Args: []string{workloadName, flags.ServiceRefFlagName, "database=services.tanzu.vmware.com/v1alpha1:PostgreSQL:my-prod-db", flags.WaitFlagName, flags.YesFlagName, flags.WaitTimeoutFlagName, "1ns"},
Args: []string{workloadName, flags.ServiceRefFlagName, "database=services.tanzu.vmware.com/v1alpha1:PostgreSQL:my-prod-db", flags.WaitFlagName, flags.YesFlagName, flags.WaitTimeoutFlagName, "1ns", flags.DelayTimeFlagName, "0ns"},
GivenObjects: []client.Object{
parent.
SpecDie(func(d *diecartov1alpha1.WorkloadSpecDie) {
Expand Down Expand Up @@ -2102,7 +2102,7 @@ Error waiting for ready condition: timeout after 1ns waiting for "my-workload" t
{
Name: "update - wait timeout when there is no transition time",
Skip: runtm.GOOS == "windows",
Args: []string{workloadName, flags.ServiceRefFlagName, "database=services.tanzu.vmware.com/v1alpha1:PostgreSQL:my-prod-db", flags.WaitFlagName, flags.YesFlagName, flags.WaitTimeoutFlagName, "1ns"},
Args: []string{workloadName, flags.ServiceRefFlagName, "database=services.tanzu.vmware.com/v1alpha1:PostgreSQL:my-prod-db", flags.WaitFlagName, flags.YesFlagName, flags.WaitTimeoutFlagName, "1ns", flags.DelayTimeFlagName, "0ns"},
GivenObjects: []client.Object{
parent.
SpecDie(func(d *diecartov1alpha1.WorkloadSpecDie) {
Expand Down Expand Up @@ -2209,7 +2209,7 @@ Error waiting for status change: timeout after 1ns waiting for "my-workload" to
{
Name: "update - wait timeout when there is no ready cond",
Skip: runtm.GOOS == "windows",
Args: []string{workloadName, flags.ServiceRefFlagName, "database=services.tanzu.vmware.com/v1alpha1:PostgreSQL:my-prod-db", flags.WaitFlagName, flags.YesFlagName, flags.WaitTimeoutFlagName, "1ns"},
Args: []string{workloadName, flags.ServiceRefFlagName, "database=services.tanzu.vmware.com/v1alpha1:PostgreSQL:my-prod-db", flags.WaitFlagName, flags.YesFlagName, flags.WaitTimeoutFlagName, "1ns", flags.DelayTimeFlagName, "0ns"},
GivenObjects: []client.Object{
parent.
SpecDie(func(d *diecartov1alpha1.WorkloadSpecDie) {
Expand Down Expand Up @@ -2302,7 +2302,7 @@ Error waiting for status change: timeout after 1ns waiting for "my-workload" to
{
Name: "update - wait for timestamp change error with timeout",
Skip: runtm.GOOS == "windows",
Args: []string{workloadName, flags.ServiceRefFlagName, "database=services.tanzu.vmware.com/v1alpha1:PostgreSQL:my-prod-db", flags.WaitFlagName, flags.YesFlagName, flags.WaitTimeoutFlagName, "1ns"},
Args: []string{workloadName, flags.ServiceRefFlagName, "database=services.tanzu.vmware.com/v1alpha1:PostgreSQL:my-prod-db", flags.WaitFlagName, flags.YesFlagName, flags.WaitTimeoutFlagName, "1ns", flags.DelayTimeFlagName, "0ns"},
GivenObjects: []client.Object{
parent.
SpecDie(func(d *diecartov1alpha1.WorkloadSpecDie) {
Expand Down Expand Up @@ -2412,7 +2412,7 @@ Error waiting for status change: timeout after 1ns waiting for "my-workload" to
},
{
Name: "update - wait error for false condition",
Args: []string{workloadName, flags.ServiceRefFlagName, "database=services.tanzu.vmware.com/v1alpha1:PostgreSQL:my-prod-db", flags.WaitFlagName, flags.YesFlagName},
Args: []string{workloadName, flags.ServiceRefFlagName, "database=services.tanzu.vmware.com/v1alpha1:PostgreSQL:my-prod-db", flags.WaitFlagName, flags.YesFlagName, flags.DelayTimeFlagName, "0ns"},
GivenObjects: []client.Object{
parent.
SpecDie(func(d *diecartov1alpha1.WorkloadSpecDie) {
Expand Down Expand Up @@ -2523,7 +2523,7 @@ Error waiting for ready condition: Failed to become ready: a hopefully informati
},
{
Name: "update - successful wait for ready condition",
Args: []string{workloadName, flags.ServiceRefFlagName, "database=services.tanzu.vmware.com/v1alpha1:PostgreSQL:my-prod-db", flags.WaitFlagName, flags.YesFlagName},
Args: []string{workloadName, flags.ServiceRefFlagName, "database=services.tanzu.vmware.com/v1alpha1:PostgreSQL:my-prod-db", flags.WaitFlagName, flags.YesFlagName, flags.DelayTimeFlagName, "0ns"},
GivenObjects: []client.Object{
parent.
SpecDie(func(d *diecartov1alpha1.WorkloadSpecDie) {
Expand Down Expand Up @@ -5356,7 +5356,7 @@ status:
Name: "output workload after update in yaml format with wait error",
Args: []string{workloadName, flags.ServiceRefFlagName,
"database=services.tanzu.vmware.com/v1alpha1:PostgreSQL:my-prod-db",
flags.OutputFlagName, printer.OutputFormatYml, flags.WaitFlagName, flags.DelayTimeFlagName, "0ms"},
flags.OutputFlagName, printer.OutputFormatYml, flags.WaitFlagName, flags.DelayTimeFlagName, "0ns"},
Prepare: func(t *testing.T, ctx context.Context, config *cli.Config, tc *clitesting.CommandTestCase) (context.Context, error) {
workload := &cartov1alpha1.Workload{
ObjectMeta: metav1.ObjectMeta{
Expand Down Expand Up @@ -5499,7 +5499,7 @@ status:
Name: "console interaction - output workload after update in yaml format with wait",
Args: []string{workloadName, flags.ServiceRefFlagName,
"database=services.tanzu.vmware.com/v1alpha1:PostgreSQL:my-prod-db",
flags.OutputFlagName, printer.OutputFormatYml, flags.WaitFlagName, flags.DelayTimeFlagName, "0ms"},
flags.OutputFlagName, printer.OutputFormatYml, flags.WaitFlagName, flags.DelayTimeFlagName, "0ns"},
Prepare: func(t *testing.T, ctx context.Context, config *cli.Config, tc *clitesting.CommandTestCase) (context.Context, error) {
workload := &cartov1alpha1.Workload{
ObjectMeta: metav1.ObjectMeta{
Expand Down
10 changes: 5 additions & 5 deletions pkg/commands/workload_create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ status:
{
Name: "create - output yaml with wait",
Args: []string{workloadName, flags.GitRepoFlagName, gitRepo, flags.GitBranchFlagName, gitBranch,
flags.OutputFlagName, printer.OutputFormatYaml, flags.WaitFlagName, flags.YesFlagName},
flags.OutputFlagName, printer.OutputFormatYaml, flags.WaitFlagName, flags.YesFlagName, flags.DelayTimeFlagName, "0ns"},
GivenObjects: givenNamespaceDefault,
Prepare: func(t *testing.T, ctx context.Context, config *cli.Config, tc *clitesting.CommandTestCase) (context.Context, error) {
workload := &cartov1alpha1.Workload{
Expand Down Expand Up @@ -310,7 +310,7 @@ status:
},
{
Name: "wait error for false condition",
Args: []string{workloadName, flags.GitRepoFlagName, gitRepo, flags.GitBranchFlagName, gitBranch, flags.YesFlagName, flags.WaitFlagName},
Args: []string{workloadName, flags.GitRepoFlagName, gitRepo, flags.GitBranchFlagName, gitBranch, flags.YesFlagName, flags.WaitFlagName, flags.DelayTimeFlagName, "0ns"},
Prepare: func(t *testing.T, ctx context.Context, config *cli.Config, tc *clitesting.CommandTestCase) (context.Context, error) {
workload := &cartov1alpha1.Workload{
ObjectMeta: metav1.ObjectMeta{
Expand Down Expand Up @@ -463,7 +463,7 @@ Error waiting for ready condition: timeout after 1ns waiting for "my-workload" t
},
{
Name: "successful wait for ready cond",
Args: []string{workloadName, flags.GitRepoFlagName, gitRepo, flags.GitBranchFlagName, gitBranch, flags.YesFlagName, flags.WaitFlagName},
Args: []string{workloadName, flags.GitRepoFlagName, gitRepo, flags.GitBranchFlagName, gitBranch, flags.YesFlagName, flags.WaitFlagName, flags.DelayTimeFlagName, "0ns"},
Prepare: func(t *testing.T, ctx context.Context, config *cli.Config, tc *clitesting.CommandTestCase) (context.Context, error) {
workload := &cartov1alpha1.Workload{
ObjectMeta: metav1.ObjectMeta{
Expand Down Expand Up @@ -756,7 +756,7 @@ Error: workload "default/my-workload" already exists
},
{
Name: "watcher error",
Args: []string{workloadName, flags.GitRepoFlagName, gitRepo, flags.GitBranchFlagName, gitBranch, flags.YesFlagName, flags.WaitFlagName},
Args: []string{workloadName, flags.GitRepoFlagName, gitRepo, flags.GitBranchFlagName, gitBranch, flags.YesFlagName, flags.WaitFlagName, flags.DelayTimeFlagName, "0ns"},
Prepare: func(t *testing.T, ctx context.Context, config *cli.Config, tc *clitesting.CommandTestCase) (context.Context, error) {
fakewatch := watchfakes.NewFakeWithWatch(true, config.Client, []watch.Event{})
ctx = watchhelper.WithWatcher(ctx, fakewatch)
Expand Down Expand Up @@ -1901,7 +1901,7 @@ Error waiting for ready condition: failed to create watcher
Name: "output workload after create in json format with wait error",
GivenObjects: givenNamespaceDefault,
Args: []string{workloadName, flags.GitRepoFlagName, gitRepo, flags.GitBranchFlagName, gitBranch,
flags.TypeFlagName, "web", flags.OutputFlagName, printer.OutputFormatJson, flags.WaitFlagName},
flags.TypeFlagName, "web", flags.OutputFlagName, printer.OutputFormatJson, flags.WaitFlagName, flags.DelayTimeFlagName, "0ns"},
WithConsoleInteractions: func(t *testing.T, c *expect.Console) {
c.ExpectString(clitesting.ToInteractTerminal("Do you want to create this workload? [yN]: "))
c.Send(clitesting.InteractInputLine("y"))
Expand Down

0 comments on commit 4dd7eec

Please sign in to comment.