-
-
Notifications
You must be signed in to change notification settings - Fork 248
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
Added test for render validation of PostService #2389
base: series/2.x
Are you sure you want to change the base?
Added test for render validation of PostService #2389
Conversation
6784705
to
0b78089
Compare
0b78089
to
8e96196
Compare
How about using zio-test? It's better to stick with one library. |
55e581d
to
f2130cb
Compare
5bbb8f9
to
5239c68
Compare
c8bac23
to
92bde40
Compare
} | ||
|
||
object SnapshotTest { | ||
val `.git`: Path = Path.of(".git") | ||
val cwd: Path = Path.of(sys.props("user.dir")) | ||
|
||
val projectRoot: Path = { | ||
lazy val projectRoot: Path = { |
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.
For scripted test this will fail so better not evaluate it.
|
||
def write(): TestResult = { |
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.
Moving helper function out for reuse
// at least don't take the git lock multiple times from same process. this can still fail if concurrent processes try to take it. | ||
GitLock.synchronized { | ||
// allow failing external command, but complain to stderr | ||
exitCode = |
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.
execution can fail with exitCode so we need to check it as it won`t be throwing exception
case Success(existing) if existing.equals(content) => | ||
assert(())(Assertion.anything) | ||
case Success(_) => | ||
write(path, content) |
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.
Only if it changed we attempt to update it and add it to git.
In case of scripted test, it will be updated, but test will fail on adding to git. (running from /tmp ) - as warning,
but snapshot will be updated for second run.
build.sbt
Outdated
@@ -216,7 +216,8 @@ lazy val tools = project | |||
"dev.zio" %% "zio-test" % zioVersion % Test, | |||
"dev.zio" %% "zio-test-sbt" % zioVersion % Test, | |||
"dev.zio" %% "zio-json" % zioJsonVersion % Test | |||
) | |||
), | |||
Test / publishArtifact := true |
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.
For local builds we need to provide test classes of project tools (SnapshotTest)
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.
It's not going to try to publish something to Maven when we do a new release?
"-Xmx1024M", | ||
"-Xss4M", | ||
"-Dplugin.version=" + version.value, | ||
s"-Dproject.dir=${baseDirectory.value.getAbsolutePath}" |
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.
Since sbt-test run from /tmp we add project.dir property to be able to resolve and update graphql snapshot file.
build.sbt
Outdated
@@ -216,7 +216,8 @@ lazy val tools = project | |||
"dev.zio" %% "zio-test" % zioVersion % Test, | |||
"dev.zio" %% "zio-test-sbt" % zioVersion % Test, | |||
"dev.zio" %% "zio-json" % zioJsonVersion % Test | |||
) | |||
), | |||
Test / publishArtifact := true |
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.
It's not going to try to publish something to Maven when we do a new release?
5e1a352
to
3b50ae7
Compare
Test / publishArtifact := true, | ||
|
||
// Include test artifact for publishLocal | ||
publishLocalConfiguration := { | ||
val config = publishLocalConfiguration.value | ||
val testArtifacts = (Test / packagedArtifacts).value | ||
config.withArtifacts(config.artifacts ++ testArtifacts).withOverwrite(true) | ||
}, | ||
// Exclude test artifact from publish | ||
publishConfiguration := { | ||
val config = publishConfiguration.value | ||
config | ||
.withArtifacts(config.artifacts.filterNot { case (artifact, _) => | ||
artifact.configurations.exists(_.name == "test") | ||
}) | ||
.withOverwrite(true) | ||
} |
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.
This should prevent test compile classes from being included on publish, but allow for it for publishLocal.
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.
LGTM, @kyri-petrou you wanna check it?
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.
Sorry for the delay in reviewing, I've been quite busy the past week
```sbt | ||
project codegenSbt | ||
++2.12.20 |
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.
Perhaps change this to +2.12
instead so that we don't have to update it on scala version updates
"dev.zio" %% "zio-test" % "2.1.9" % Test, | ||
"dev.zio" %% "zio-test-sbt" % "2.1.9" % Test |
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.
I don't think Scala Steward will update this. Any chance that we can place versions somewhere where we can reuse them? Or simpler (less changes) perhaps include them in the BuildInfo object for the publishLocal configuration?
Also, I don't think these lines are correctly formatted
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.
Updated formatting + README.
Did not see any .scala-steward.conf, is it part of github setup?
Could it be better to append sub projects to .scala-steward`s buildRoots?
3b50ae7
to
d4abf0a
Compare
Added basic test for render validation of PostService.
Proposing to add tests for render validation of compiletime generated services.
This will allow us to verify and better track behavior of new implementations. when using code first approach for GraphQl.