From c3bdafd4458908f08926bf217340fcea28b9f735 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89douard=20Lopez?= Date: Fri, 26 Jan 2024 01:21:34 +0100 Subject: [PATCH] docs: screenshot check_for_new_release & container_detection --- docs/components/features-list.md | 18 ++++++++- tests/screenshot.test.doc.fish | 65 ++++++++++++++++---------------- 2 files changed, 49 insertions(+), 34 deletions(-) diff --git a/docs/components/features-list.md b/docs/components/features-list.md index 60a893bc..e74d091d 100644 --- a/docs/components/features-list.md +++ b/docs/components/features-list.md @@ -14,6 +14,14 @@ set --universal pure_check_for_new_release false ``` +=== "Enabled (with update)" + + ![screenshot pure_check_for_new_release=true,with-update](../assets/screenshots/pure_check_for_new_release=true,with-update.png) + +=== "Enabled (no update)" + + ![screenshot pure_check_for_new_release=true,no-update](../assets/screenshots/pure_check_for_new_release=true,no-update.png) + ### Container Detection (Docker) | Option | Default | Description | @@ -21,7 +29,15 @@ | **`pure_enable_container_detection`** | `true` | `false`: Do not check _pure_ runs inside a container (e.g. `docker`, `podman`, `LXC`/`LXD`, etc.).
:warning: Detection is a bit [tricky across OSes][container-detection]. | | **`pure_symbol_container_prefix`** | | Prefix when being inside a container ([to customize][to-set]) | -[container-detection]: https://stackoverflow.com/q/23513045/802365 +[container-detection]: + +=== "Enabled (inside a container)" + + ![screenshot pure_enable_container_detection=true,inside](../assets/screenshots/pure_enable_container_detection=true,inside.png) + +=== "Enabled (outside a container)" + + ![screenshot pure_enable_container_detection=true,outside](../assets/screenshots/pure_enable_container_detection=true,outside.png) ### Current Working Directory diff --git a/tests/screenshot.test.doc.fish b/tests/screenshot.test.doc.fish index 8a47317f..48616431 100644 --- a/tests/screenshot.test.doc.fish +++ b/tests/screenshot.test.doc.fish @@ -1,9 +1,12 @@ source (status dirname)/fixtures/constants.fish +source (status dirname)/mocks/spectra.fish + @echo (_print_filename (status filename)) function before_each _purge_configs - source ../conf.d/pure.fish + source (status dirname)/../conf.d/pure.fish + _clean_all_mocks end function screenshot \ @@ -12,7 +15,7 @@ function screenshot \ name \ action - set --query action; or set action fish_prompt + set --query action[1]; or set action fish_prompt $action \ @@ -23,45 +26,41 @@ function screenshot \ # --background-color white # some text are invisible with white background end -function boolean_test \ - --description "Take screenshot" \ - --argument-names \ - name \ - setup_context \ - value \ - action +if set --query CI + before_each + @test "screenshot: pure_check_for_new_release=true,with-update" ( + set --universal pure_check_for_new_release true + set --global pure_version 0.0.1 + _mock_response curl '"tag_name": "v9.9.9",' + + screenshot "pure_check_for_new_release=true,with-update" _pure_check_for_new_release + + ) $status -eq $SUCCESS - echo $value - echo $action - echo $setup_context before_each - @test "screenshot `$name $value`" ( - $setup_context - set --universal $name $value - screenshot "$name=$value" $action + @test "screenshot: pure_check_for_new_release=true,no-update" ( + set --universal pure_check_for_new_release true + set --global pure_version 0.0.1 + _mock_response curl '"tag_name": "v0.0.1",' + + screenshot "pure_check_for_new_release=true,no-update" _pure_check_for_new_release ) $status -eq $SUCCESS -end -if set --query CI - function setup - set --universal pure_check_for_new_release true - set --universal pure_version 0.0.1 - function curl - echo '"tag_name": "v0.0.1",' - end # mock - end - # boolean_test pure_check_for_new_release setup false _pure_check_for_new_release before_each - @test "screenshot `pure_check_for_new_release true`" ( - set --universal pure_check_for_new_release true - set --universal pure_version 0.0.1 - function curl - echo '"tag_name": "v0.0.1",' - end # mock + @test "screenshot: pure_enable_container_detection=true,inside" ( + set --universal pure_enable_container_detection true + set --universal pure_symbol_container_prefix "🐋" - screenshot "pure_check_for_new_release=true" _pure_check_for_new_release + screenshot "pure_enable_container_detection=true,inside" + ) $status -eq $SUCCESS + + before_each + @test "screenshot: pure_enable_container_detection=true,outside" ( + set --universal pure_enable_container_detection true + _mock_exit_status _pure_is_inside_container $FAILURE + screenshot "pure_enable_container_detection=true,outside" ) $status -eq $SUCCESS