Skip to content

Conversation

@dylandoamaral
Copy link
Contributor

@dylandoamaral dylandoamaral commented Dec 30, 2022

🚧 On hold, it's not clear if this is useful as it is. It creates a lot of issue, given it doesn't really compose at the moment. 🚧

Here is the missing step for now :

  • Create a way to simply create spark macros close to ZIO way of doing tests
  • Validate the design
  • Add macro for assertSpark
  • Modify macro to get a better output message

@dylandoamaral dylandoamaral changed the title feat: add zio spark test assertion system Draft: feat: add zio spark test assertion system Dec 30, 2022
@dylandoamaral dylandoamaral changed the title Draft: feat: add zio spark test assertion system feat: add zio spark test assertion system Dec 30, 2022
@dylandoamaral dylandoamaral marked this pull request as draft December 30, 2022 10:06
@ahoy-jon
Copy link
Member

Why does it need a macro ? Spark produce values (seq(jsonoids)) that need ...

Do you have an example for the syntax?

@dylandoamaral
Copy link
Contributor Author

Why does it need a macro ? Spark produce values (seq(jsonoids)) that need ...

Do you have an example for the syntax?

For the moment it generates something like this :
/**

  • What we have :
  • Assertion failed:
    ✗ false was not true
    Dataset was not empty
    Dataset(1, 2, 3) did not satisfy isEmpty
    Dataset(1, 2, 3) = false
    at ...
    */

You need the macro to retrieve the value (Dataset(1, 2, 3)) and the assertion (isEmpty) from our custom assert function.

@dylandoamaral dylandoamaral marked this pull request as ready for review January 2, 2023 15:15
Copy link
Member

@ahoy-jon ahoy-jon left a comment

Choose a reason for hiding this comment

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

Reviewed, macro are not needed for this use case.
Are we adding them for something else later on? or related to quill / iskra?

I don't see the use case here, unless we are moving fast to explain advanced matchers :

df.expectAtLeast(
  row(__, 13), 
  row.as[Person].assertTrue(_.name.contains("toto") || _.age > 10)
)

But that doesn't look like the actual direction.

@dylandoamaral could you explain why we need the macro for this PR ? Can the macro be reserved for another PR for advanced predicate checks?

I will take a look at zio-test to see if they use macro outside code Location or assertTrue.

CrossVersion.partialVersion(scalaVersion.value).get._1 match {
case 3 => Seq.empty
case _ => Seq(
"org.scala-lang" % "scala-reflect" % scalaVersion.value % "provided",
Copy link
Member

Choose a reason for hiding this comment

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

pb, the user need the macro as a dependencie, as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dylandoamaral
Copy link
Contributor Author

Reviewed, macro are not needed for this use case. Are we adding them for something else later on? or related to quill / iskra?

I don't see the use case here, unless we are moving fast to explain advanced matchers :

df.expectAtLeast(
  row(__, 13), 
  row.as[Person].assertTrue(_.name.contains("toto") || _.age > 10)
)

But that doesn't look like the actual direction.

@dylandoamaral could you explain why we need the macro for this PR ? Can the macro be reserved for another PR for advanced predicate checks?

I will take a look at zio-test to see if they use macro outside code Location or assertTrue.

I explained above why I use the macro, it is exactly the same code from zio assert.

@ahoy-jon ahoy-jon marked this pull request as draft January 4, 2023 16:34
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.

3 participants