Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(tests): standardize messages #448

Merged
merged 2 commits into from
Jun 27, 2024

Conversation

tenthirtyam
Copy link
Collaborator

Description

Standardizes the messages returned in tests.

Examples:

if err != nil {
-    t.Fatalf("should not fail: %s", err.Error())
+    t.Fatalf("unexpected error: '%s'", err)
}
if action := c.step.Run(context.TODO(), state); action != c.expectedAction {
-    t.Fatalf("unexpected action %v", action)
+    t.Fatalf("unexpected action: expected '%#v', but returned '%#v'", c.expectedAction, action)
}
if c.fail {
-    t.Fatalf("expected to fail but it didn't")
+    t.Fatal("unexpected success: expected failure")
}
if !driverMock.DatastoreMock.UploadFileCalled {
-    t.Fatalf("datastore.UploadFile should be called.")
+    t.Fatalf("unexpected result: '%s' should be called", "UploadFile")
}

Testing

packer-plugin-vsphere on  refactor(tests)/standardize-messagesgo fmt ./...

packer-plugin-vsphere on  refactor(tests)/standardize-messagesmake build

packer-plugin-vsphere on  refactor(tests)/standardize-messagesmake generate
2024/06/24 10:18:02 Copying "docs" to ".docs/"
2024/06/24 10:18:02 Replacing @include '...' calls in .docs/
Compiling MDX docs in '.docs' to Markdown in '.web-docs'...

packer-plugin-vsphere on  refactor(tests)/standardize-messagesmake test
?       github.com/hashicorp/packer-plugin-vsphere      [no test files]
?       github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/testing       [no test files]
ok      github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/clone        2.360s
?       github.com/hashicorp/packer-plugin-vsphere/examples/driver      [no test files]
?       github.com/hashicorp/packer-plugin-vsphere/version      [no test files]
ok      github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common       5.195s
ok      github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/driver       7.213s
ok      github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/iso  5.585s
ok      github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/supervisor   8.741s
ok      github.com/hashicorp/packer-plugin-vsphere/post-processor/vsphere       3.655s
ok      github.com/hashicorp/packer-plugin-vsphere/post-processor/vsphere-template      4.749s

packer-plugin-vsphere on  refactor(tests)/standardize-messagesmake dev
packer plugins install --path packer-plugin-vsphere "github.com/hashicorp/vsphere"
Successfully installed plugin github.com/hashicorp/vsphere from /Users/johnsonryan/Library/Mobile Documents/com~apple~CloudDocs/Code/Work/packer-plugin-vsphere/packer-plugin-vsphere to /Users/johnsonryan/.packer.d/plugins/github.com/hashicorp/vsphere/packer-plugin-vsphere_v1.3.1-dev_x5.0_darwin_amd64

Standardizes the messages returned in tests.

Signed-off-by: Ryan Johnson <[email protected]>
@tenthirtyam tenthirtyam added this to the v1.3.1 milestone Jun 24, 2024
@tenthirtyam tenthirtyam requested a review from nywilken June 24, 2024 14:29
@tenthirtyam tenthirtyam self-assigned this Jun 24, 2024
@tenthirtyam tenthirtyam requested a review from a team as a code owner June 24, 2024 14:29
@tenthirtyam
Copy link
Collaborator Author

Ah! An update from the SDK change! Doh!

@tenthirtyam
Copy link
Collaborator Author

I missed that because Lucas and were needing to do that in #431 last week.

Copy link
Contributor

@nywilken nywilken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@nywilken nywilken merged commit 55b45c0 into main Jun 27, 2024
12 checks passed
@nywilken nywilken deleted the refactor(tests)/standardize-messages branch June 27, 2024 21:06
@hashicorp hashicorp locked as resolved and limited conversation to collaborators Jun 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants