-
Notifications
You must be signed in to change notification settings - Fork 571
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
Migrate from AsssertJ to AssertK #3178
Conversation
d0b7ef4
to
7cb2f4b
Compare
7cb2f4b
to
174e8cc
Compare
@@ -69,7 +72,7 @@ class ManifestParseTest { | |||
""".trimMargin() | |||
|
|||
val modules = parseManifestModules(yaml) | |||
assertThat(modules.keys).containsExactly("one", "two") | |||
assertThat(modules.getValue("one").dependencies).containsExactly("two") | |||
assertThat(modules.keys.toList()).containsExactly("one", "two") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
containsExactly –> containsOnly
willowtreeapps/assertk#489
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lmao
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But assertJ containsExactly also checks the order, which is why I keep this assertion here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but sets don't have ordering... so
@@ -827,7 +830,7 @@ class WireCompilerTest { | |||
private fun assertOutputs(target: TargetLanguage, outputs: Array<String>, suffix: String = "") { | |||
val filesAfter = paths | |||
assertThat(filesAfter.size) | |||
.overridingErrorMessage(filesAfter.toString()) | |||
// .overridingErrorMessage(filesAfter.toString()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assertThat(filesAfter).hasSize(outputs.size)
.cause() // Synthetic exception added by coroutines in StackTraceRecovery.kt. | ||
.cause() | ||
.hasMessage("boom!") | ||
assertThat(expected).all { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
switch to assertFailsWith<IOException>
// |Expected :$message (unknownFields: `${(message as com.squareup.wire.Message<*, *>).unknownFields.hex()}`) | ||
// |Actual :$fromJson (unknownFields: `${(fromJson as com.squareup.wire.Message<*, *>).unknownFields.hex()}`) | ||
// """.trimMargin() | ||
// } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assertThat(fromJson, displayActual = {...})
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very nice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lots of the !!
could be replaced with inline isNotNull()
assertions, but it doesn't really matter all that much.
assertThat(filesAfter.size) | ||
.overridingErrorMessage(filesAfter.toString()) | ||
// .overridingErrorMessage(filesAfter.toString()) | ||
.isEqualTo(outputs.size) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can do
assertThat(filesAfter)
.size()
.isEqualTo(outputs.size)
which should include the list if it fails.
@@ -335,7 +350,7 @@ class GrpcClientTest { | |||
delay(200) | |||
responseChannel.cancel() | |||
mockService.awaitSuccess() | |||
assertThat(callReference.get()?.isCanceled()).isTrue() | |||
assertThat(callReference.get()!!.isCanceled()).isTrue() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The need to do this !!
is fixed on AssertK trunk
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just waiting for a release, really
@@ -459,7 +474,7 @@ class GrpcClientTest { | |||
|
|||
val latch = Mutex(locked = true) | |||
requestChannel.invokeOnClose { expected -> | |||
assertThat(expected).isInstanceOf(CancellationException::class.java) | |||
assertThat(expected!!).isInstanceOf<CancellationException>() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly, the need to do this !!
is fixed on AssertK trunk
assertThat(expected).all { | ||
hasMessage("gRPC transport failure (HTTP status=200, grpc-status=null, grpc-message=null)") | ||
// Synthetic exception added by coroutines in StackTraceRecovery.kt. | ||
prop(Throwable::cause) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prop(Throwable::cause) | |
cause() |
// Synthetic exception added by coroutines in StackTraceRecovery.kt. | ||
prop(Throwable::cause) | ||
.isNotNull() | ||
.prop(Throwable::cause) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.prop(Throwable::cause) | |
.cause() |
@@ -15,6 +15,7 @@ | |||
*/ | |||
package com.squareup.wire | |||
|
|||
import assertk.assertions.message |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these really used? Or was this from some kind of automated refactor?
174e8cc
to
dea98d6
Compare
dea98d6
to
c394f17
Compare
I addressed all comments, thank you |
No description provided.