Skip to content
New issue

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

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

Already on GitHub? # to your account

Removing specs from finagle/finagle-native test. #294

Closed
wants to merge 3 commits into from
Closed

Removing specs from finagle/finagle-native test. #294

wants to merge 3 commits into from

Conversation

adamdecaf
Copy link
Contributor

Going along with the corresponding issue #290 and my other PR on the subject #292

Problem

In order to upgrade to 2.11 (and as part of a larger twitter initiative)
specs has to be removed. This is one small step in doing so.

Solution

Remove specs, replace with the standard FunSuite / assert way of
testing.

Result.

Hopefully nothing will change. Except for removing specs.
"openssl-root.conf"
)

def init() {
Copy link
Contributor

Choose a reason for hiding this comment

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

instead of calling an init method, the style we typically use is to either make a Context class that we construct and import members from, or make a wrapper method that can do the construction for us. this means that we don't have to worry about sharing objects.

For example:

class Ctx {
  val input = ...
}

val ctx = new Ctx()
import ctx._

or

def exec(fn: Input => Unit) {
...
}

exec { input =>

}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alright, I'll switch it over to that style.

@adamdecaf
Copy link
Contributor Author

Is that test failure something local to the server it ran on? I don't get that locally.

@mosesn
Copy link
Contributor

mosesn commented Jul 15, 2014

Hmm, yeah, it's a very weird failure. It hasn't happened historically, though. My guess is it's just flaky.

LGTM

)

class Context {
// before we run any tests, construct the chain
Copy link
Contributor

Choose a reason for hiding this comment

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

There's no need for a Context class, you should just run the code inside Context before executing the test.
(I think this is the cause of the test failure on TravisCI)

Copy link
Contributor

Choose a reason for hiding this comment

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

Haha, I literally told him the opposite. I like having a Context class because it makes it clear that you're not sharing any mutable state. Why do you think it would cause a test failure?

Copy link
Contributor

Choose a reason for hiding this comment

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

The CertChainOutput that you create at line 56 will fail because you never create this context (never execute the constructor to be precise).
In general, I agree with you, but here you don't share anything with the instance of Context, you're just counting on the side effect of creating an instance.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just to make sure I'm reading this right you're saying to just run the code in Context, rather then newing up the class? Shouldn't the block in the class be ran upon instantiation?

Copy link
Contributor

Choose a reason for hiding this comment

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

You read me correctly.
The block in the class should be ran before initializing CertChainOutput.

@adamdecaf
Copy link
Contributor Author

Updated, does it look better now?

@stevegury
Copy link
Contributor

It does look better!
I'm pulling this internally, you should see it on Github soon.

@travisbrown
Copy link
Contributor

Now on GitHub.

@travisbrown travisbrown closed this Aug 6, 2014
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants