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

Instance attributes #908

Closed
wants to merge 0 commits into from
Closed

Instance attributes #908

wants to merge 0 commits into from

Conversation

petderek
Copy link
Contributor

@petderek petderek commented Aug 1, 2017

Summary

Refactored / cleaned up tests. This builds on top of #893

Implementation details

  • Using table-driven tests

Testing

  • Builds on Linux (make release)
  • Builds on Windows (go build -out amazon-ecs-agent.exe ./agent)
  • Unit tests on Linux (make test) pass
  • Unit tests on Windows (go test -timeout=25s ./agent/...) pass
  • Integration tests on Linux (make run-integ-tests) pass
  • Integration tests on Windows (.\scripts\run-integ-tests.ps1) pass
  • Functional tests on Linux (make run-functional-tests) pass
  • Functional tests on Windows (.\scripts\run-functional-tests.ps1) pass

This contribution is under the terms of the Apache 2.0 License: yes

@petderek petderek requested review from adnxn and aaithal August 1, 2017 18:44
if result != specifiedValue {
t.Error("Expected " + specifiedValue + ", got " + result)
}
assert.Equal(t, result, specifiedValue, "Expected "+specifiedValue+", got "+result)
Copy link
Contributor

Choose a reason for hiding this comment

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

You don't need the "Expected "+specifiedValue+", got "+result, since assert.Equal will do that for you.

Also, it should be assert.Equal(t, expected, actual, "message"), so you'll want to swap the order.


for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
assert.Equal(t, ZeroOrNil(tc.param), tc.expected)
Copy link
Contributor

Choose a reason for hiding this comment

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

assert.Equal(t, tc.expected, ZeroOrNil(tc.param), tc.name)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

tc.name will be included in the subtest output -- still want it in the message too?

Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't hurt to be there. In the subtest output it'll replace some characters ( will become _, for example), but the message can have the actual string.

Copy link
Contributor

@aaithal aaithal left a comment

Choose a reason for hiding this comment

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

lgtm. tables all the way!

@@ -44,7 +44,8 @@ func ZeroOrNil(obj interface{}) bool {
if obj == nil {
return true
}
if value.Kind() == reflect.Slice || value.Kind() == reflect.Array {
switch value.Kind() {
case reflect.Slice, reflect.Array, reflect.Map:
Copy link
Contributor

Choose a reason for hiding this comment

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

this is neat. =]

{map[string]string{"foo": "bar"}, false, "map[string]string{foo:bar} is not zero or nil"},
}

for _, tc := range testCases {
Copy link
Contributor

Choose a reason for hiding this comment

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

ohhh i see what's going on here, this is pretty cool. i need more tables in my life.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants