cloud/e2e: Additional context for failing to find expected output

This just gives a little extra information to work with when trying to
understand why a test failed. It doesn't change what any of the tests are
actually trying to test.
This commit is contained in:
Martin Atkins 2021-11-16 15:03:43 -08:00
parent e5172fea95
commit c28b57b4d6
9 changed files with 39 additions and 38 deletions

View File

@ -212,9 +212,9 @@ func Test_terraform_apply_autoApprove(t *testing.T) {
} }
if tfCmd.expectedCmdOutput != "" { if tfCmd.expectedCmdOutput != "" {
_, err := exp.ExpectString(tfCmd.expectedCmdOutput) got, err := exp.ExpectString(tfCmd.expectedCmdOutput)
if err != nil { if err != nil {
t.Fatal(err) t.Fatalf("error while waiting for output\nwant: %s\nerror: %s\noutput\n%s", tfCmd.expectedCmdOutput, err, got)
} }
} }

View File

@ -107,9 +107,9 @@ func Test_backend_apply_before_init(t *testing.T) {
} }
if tfCmd.expectedCmdOutput != "" { if tfCmd.expectedCmdOutput != "" {
_, err := exp.ExpectString(tfCmd.expectedCmdOutput) got, err := exp.ExpectString(tfCmd.expectedCmdOutput)
if err != nil { if err != nil {
t.Fatal(err) t.Fatalf("error while waiting for output\nwant: %s\nerror: %s\noutput\n%s", tfCmd.expectedCmdOutput, err, got)
} }
} }

View File

@ -74,9 +74,9 @@ func Test_init_with_empty_tags(t *testing.T) {
} }
if tfCmd.expectedCmdOutput != "" { if tfCmd.expectedCmdOutput != "" {
_, err := exp.ExpectString(tfCmd.expectedCmdOutput) got, err := exp.ExpectString(tfCmd.expectedCmdOutput)
if err != nil { if err != nil {
t.Fatal(err) t.Fatalf("error while waiting for output\nwant: %s\nerror: %s\noutput\n%s", tfCmd.expectedCmdOutput, err, got)
} }
} }

View File

@ -266,9 +266,10 @@ func Test_migrate_multi_to_tfc_cloud_name_strategy(t *testing.T) {
} }
if tfCmd.expectedCmdOutput != "" { if tfCmd.expectedCmdOutput != "" {
_, err := exp.ExpectString(tfCmd.expectedCmdOutput) got, err := exp.ExpectString(tfCmd.expectedCmdOutput)
if err != nil { if err != nil {
t.Fatal(err)
t.Fatalf("error while waiting for output\nwant: %s\nerror: %s\noutput\n%s", tfCmd.expectedCmdOutput, err, got)
} }
} }
@ -554,9 +555,9 @@ func Test_migrate_multi_to_tfc_cloud_tags_strategy(t *testing.T) {
} }
if tfCmd.expectedCmdOutput != "" { if tfCmd.expectedCmdOutput != "" {
_, err := exp.ExpectString(tfCmd.expectedCmdOutput) got, err := exp.ExpectString(tfCmd.expectedCmdOutput)
if err != nil { if err != nil {
t.Fatal(err) t.Fatalf("error while waiting for output\nwant: %s\nerror: %s\noutput\n%s", tfCmd.expectedCmdOutput, err, got)
} }
} }

View File

@ -97,9 +97,9 @@ func Test_migrate_remote_backend_name_to_tfc_name(t *testing.T) {
} }
if tfCmd.expectedCmdOutput != "" { if tfCmd.expectedCmdOutput != "" {
_, err := exp.ExpectString(tfCmd.expectedCmdOutput) got, err := exp.ExpectString(tfCmd.expectedCmdOutput)
if err != nil { if err != nil {
t.Fatal(err) t.Fatalf("error while waiting for output\nwant: %s\nerror: %s\noutput\n%s", tfCmd.expectedCmdOutput, err, got)
} }
} }
@ -216,9 +216,9 @@ func Test_migrate_remote_backend_name_to_tfc_same_name(t *testing.T) {
} }
if tfCmd.expectedCmdOutput != "" { if tfCmd.expectedCmdOutput != "" {
_, err := exp.ExpectString(tfCmd.expectedCmdOutput) got, err := exp.ExpectString(tfCmd.expectedCmdOutput)
if err != nil { if err != nil {
t.Fatal(err) t.Fatalf("error while waiting for output\nwant: %s\nerror: %s\noutput\n%s", tfCmd.expectedCmdOutput, err, got)
} }
} }
@ -343,9 +343,9 @@ func Test_migrate_remote_backend_name_to_tfc_name_different_org(t *testing.T) {
} }
if tfCmd.expectedCmdOutput != "" { if tfCmd.expectedCmdOutput != "" {
_, err := exp.ExpectString(tfCmd.expectedCmdOutput) got, err := exp.ExpectString(tfCmd.expectedCmdOutput)
if err != nil { if err != nil {
t.Fatal(err) t.Fatalf("error while waiting for output\nwant: %s\nerror: %s\noutput\n%s", tfCmd.expectedCmdOutput, err, got)
} }
} }
@ -476,9 +476,9 @@ func Test_migrate_remote_backend_name_to_tfc_tags(t *testing.T) {
} }
if tfCmd.expectedCmdOutput != "" { if tfCmd.expectedCmdOutput != "" {
_, err := exp.ExpectString(tfCmd.expectedCmdOutput) got, err := exp.ExpectString(tfCmd.expectedCmdOutput)
if err != nil { if err != nil {
t.Fatal(err) t.Fatalf("error while waiting for output\nwant: %s\nerror: %s\noutput\n%s", tfCmd.expectedCmdOutput, err, got)
} }
} }
@ -600,9 +600,9 @@ func Test_migrate_remote_backend_prefix_to_tfc_name_strategy_single_workspace(t
} }
if tfCmd.expectedCmdOutput != "" { if tfCmd.expectedCmdOutput != "" {
_, err := exp.ExpectString(tfCmd.expectedCmdOutput) got, err := exp.ExpectString(tfCmd.expectedCmdOutput)
if err != nil { if err != nil {
t.Fatal(err) t.Fatalf("error while waiting for output\nwant: %s\nerror: %s\noutput\n%s", tfCmd.expectedCmdOutput, err, got)
} }
} }
@ -616,9 +616,9 @@ func Test_migrate_remote_backend_prefix_to_tfc_name_strategy_single_workspace(t
// output that matches the input. // output that matches the input.
if lenInputOutput-1 >= i { if lenInputOutput-1 >= i {
output := tfCmd.postInputOutput[i] output := tfCmd.postInputOutput[i]
_, err := exp.ExpectString(output) got, err := exp.ExpectString(output)
if err != nil { if err != nil {
t.Fatal(err) t.Fatalf("error while waiting for output\nwant: %s\nerror: %s\noutput\n%s", output, err, got)
} }
} }
} }
@ -754,9 +754,9 @@ func Test_migrate_remote_backend_prefix_to_tfc_name_strategy_multi_workspace(t *
} }
if tfCmd.expectedCmdOutput != "" { if tfCmd.expectedCmdOutput != "" {
_, err := exp.ExpectString(tfCmd.expectedCmdOutput) got, err := exp.ExpectString(tfCmd.expectedCmdOutput)
if err != nil { if err != nil {
t.Fatal(err) t.Fatalf("error while waiting for output\nwant: %s\nerror: %s\noutput\n%s", tfCmd.expectedCmdOutput, err, got)
} }
} }
@ -879,9 +879,9 @@ func Test_migrate_remote_backend_prefix_to_tfc_tags_strategy_single_workspace(t
} }
if tfCmd.expectedCmdOutput != "" { if tfCmd.expectedCmdOutput != "" {
_, err := exp.ExpectString(tfCmd.expectedCmdOutput) got, err := exp.ExpectString(tfCmd.expectedCmdOutput)
if err != nil { if err != nil {
t.Fatal(err) t.Fatalf("error while waiting for output\nwant: %s\nerror: %s\noutput\n%s", tfCmd.expectedCmdOutput, err, got)
} }
} }
@ -1035,9 +1035,9 @@ func Test_migrate_remote_backend_prefix_to_tfc_tags_strategy_multi_workspace(t *
} }
if tfCmd.expectedCmdOutput != "" { if tfCmd.expectedCmdOutput != "" {
_, err := exp.ExpectString(tfCmd.expectedCmdOutput) got, err := exp.ExpectString(tfCmd.expectedCmdOutput)
if err != nil { if err != nil {
t.Fatal(err) t.Fatalf("error while waiting for output\nwant: %s\nerror: %s\noutput\n%s", tfCmd.expectedCmdOutput, err, got)
} }
} }

View File

@ -161,9 +161,9 @@ func Test_migrate_single_to_tfc(t *testing.T) {
} }
if tfCmd.expectedCmdOutput != "" { if tfCmd.expectedCmdOutput != "" {
_, err := exp.ExpectString(tfCmd.expectedCmdOutput) got, err := exp.ExpectString(tfCmd.expectedCmdOutput)
if err != nil { if err != nil {
t.Fatal(err) t.Fatalf("error while waiting for output\nwant: %s\nerror: %s\noutput\n%s", tfCmd.expectedCmdOutput, err, got)
} }
} }

View File

@ -82,9 +82,9 @@ func Test_migrate_tfc_to_other(t *testing.T) {
} }
if tfCmd.expectedCmdOutput != "" { if tfCmd.expectedCmdOutput != "" {
_, err := exp.ExpectString(tfCmd.expectedCmdOutput) got, err := exp.ExpectString(tfCmd.expectedCmdOutput)
if err != nil { if err != nil {
t.Fatal(err) t.Fatalf("error while waiting for output\nwant: %s\nerror: %s\noutput\n%s", tfCmd.expectedCmdOutput, err, got)
} }
} }

View File

@ -252,9 +252,9 @@ func Test_migrate_tfc_to_tfc_single_workspace(t *testing.T) {
} }
if tfCmd.expectedCmdOutput != "" { if tfCmd.expectedCmdOutput != "" {
_, err := exp.ExpectString(tfCmd.expectedCmdOutput) got, err := exp.ExpectString(tfCmd.expectedCmdOutput)
if err != nil { if err != nil {
t.Fatal(err) t.Fatalf("error while waiting for output\nwant: %s\nerror: %s\noutput\n%s", tfCmd.expectedCmdOutput, err, got)
} }
} }
@ -512,9 +512,9 @@ func Test_migrate_tfc_to_tfc_multiple_workspace(t *testing.T) {
} }
if tfCmd.expectedCmdOutput != "" { if tfCmd.expectedCmdOutput != "" {
_, err := exp.ExpectString(tfCmd.expectedCmdOutput) got, err := exp.ExpectString(tfCmd.expectedCmdOutput)
if err != nil { if err != nil {
t.Fatal(err) t.Fatalf("error while waiting for output\nwant: %s\nerror: %s\noutput\n%s", tfCmd.expectedCmdOutput, err, got)
} }
} }

View File

@ -116,9 +116,9 @@ func Test_cloud_run_variables(t *testing.T) {
} }
if tfCmd.expectedCmdOutput != "" { if tfCmd.expectedCmdOutput != "" {
_, err := exp.ExpectString(tfCmd.expectedCmdOutput) got, err := exp.ExpectString(tfCmd.expectedCmdOutput)
if err != nil { if err != nil {
t.Fatalf(`Expected command output "%s", but got %v `, tfCmd.expectedCmdOutput, err) t.Fatalf("error while waiting for output\nwant: %s\nerror: %s\noutput\n%s", tfCmd.expectedCmdOutput, err, got)
} }
} }