Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
/pklPublic

Quick and dirty power assertions today!#1002

bvalyou started this conversation inShow and tell
Discussion options

I was jonesing for some better output in my test code and decided to see what I could do with a quick utility

// TestUtils.pklfunctionassertEquals(actual, expected):Boolean= actual== expected||throw("assertion failed - expected\(expected) but was\(actual)")
// ApplicationTest.pkl...facts {  ["Application backend should configure a base (unfinished) application"] {    TestUtils.assertEquals(backend.k8sResources.length,6)  }}
$ pkl test...module ApplicationTest  facts    ✘ Application backend should configure a base (unfinished) application       –– Pkl Error ––       assertion failed - expected 6 but was 5       1 | function assertEquals(actual, expected): Boolean = actual == expected || throw("assertion failed - expected \(expected) but was \(actual)")                                                                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^       at TestUtils#assertEquals              24 | TestUtils.assertEquals(backend.k8sResources.length, 6)            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^...

I'm very pleased with this quality of life improvement - it doesn't clutter the output when the test passes either:

module ApplicationTest  facts    ✔ Application backend should configure a base (unfinished) application

Interested to see what others have done in this area!

You must be logged in to vote

Replies: 0 comments

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Labels
None yet
1 participant
@bvalyou

[8]ページ先頭

©2009-2025 Movatter.jp