-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(test): Unit testing using kurtestosis (#161)
**Description** [`kurtestosis`](https://github.com/ethereum-optimism/kurtestosis), currently an MVP, is a unit test runner for `starlark`/`kurtosis`. It allows for lower-level testing that would otherwise require costly and complex environment setup and introduce unjustifiable test code complexity. This PR adds a PoC test for a simple piece of functionality, `label_from_image` function in `util.star`. The test is then executed as a part of the PR pipeline. `mise` is introduced to manage dependencies.
- Loading branch information
1 parent
825b5f5
commit 1887774
Showing
4 changed files
with
109 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[tools] | ||
|
||
# Core dependencies | ||
"ubi:ethereum-optimism/kurtestosis" = "0.0.5" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
util = import_module("/src/util.star") | ||
|
||
|
||
def test_label_from_image_short_image_name(plan): | ||
image_name = "my-image" | ||
image_label = util.label_from_image(image_name) | ||
|
||
expect.eq(image_name, image_label) | ||
|
||
|
||
def test_label_from_image_63_character_image_name(plan): | ||
image_name = ("tenletters" * 6) + "333" | ||
expect.eq(len(image_name), 63) | ||
|
||
image_label = util.label_from_image(image_name) | ||
expect.eq(len(image_label), 63) | ||
expect.eq(image_name, image_label) | ||
|
||
|
||
def test_label_from_image_64_character_image_name_no_slashes(plan): | ||
image_name = ("tenletters" * 6) + "4444" | ||
expect.eq(len(image_name), 64) | ||
|
||
image_label = util.label_from_image(image_name) | ||
expect.eq(len(image_label), 63) | ||
expect.eq(image_name[-63:], image_label) | ||
|
||
|
||
def test_label_from_image_long_image_name_no_slashes(plan): | ||
image_name = "tenletters" * 10 | ||
expect.eq(len(image_name), 100) | ||
|
||
image_label = util.label_from_image(image_name) | ||
expect.eq(len(image_label), 63) | ||
expect.eq(image_name[-63:], image_label) | ||
|
||
|
||
def test_label_from_image_long_image_name_one_slash(plan): | ||
image_suffix = "444" | ||
image_name = "/".join(["tenletters" * 6, image_suffix]) | ||
|
||
image_label = util.label_from_image(image_name) | ||
expect.eq(image_suffix, image_label) | ||
|
||
|
||
def test_label_from_image_long_image_name_more_slashes(plan): | ||
image_suffix = "/".join(["slash", "slash2", "slash3"]) | ||
image_name = "/".join(["tenletters" * 8, image_suffix]) | ||
|
||
image_label = util.label_from_image(image_name) | ||
expect.eq(image_suffix, image_label) | ||
|
||
|
||
def test_label_from_image_long_image_name_long_suffix(plan): | ||
image_suffix = "/".join(["slash", "slash2", "slash3", "what-a-suffix" * 5]) | ||
image_name = "/".join(["tenletters" * 8, image_suffix]) | ||
|
||
image_label = util.label_from_image(image_name) | ||
expect.eq(len(image_label), 63) | ||
expect.eq(image_suffix[-63:], image_label) |