| garciadeblas | 83775ba | 2025-07-23 18:35:24 +0200 | [diff] [blame] | 1 | #!/usr/bin/env -S nu --stdin |
| 2 | ####################################################################################### |
| 3 | # Copyright ETSI Contributors and Others. |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or |
| 14 | # implied. |
| 15 | # See the License for the specific language governing permissions and |
| 16 | # limitations under the License. |
| 17 | ####################################################################################### |
| 18 | |
| 19 | use std assert |
| 20 | use ../../krm * |
| 21 | use ./keypair.nu * |
| 22 | use ./concatenate.nu * |
| 23 | use ./convert.nu * |
| 24 | use ./strategicmergepatch.nu * |
| 25 | use ./jsonpatch.nu * |
| 26 | use ./generator.nu * |
| 27 | use ./patch.nu * |
| 28 | use ./overlaypatch.nu * |
| 29 | |
| 30 | |
| 31 | # Test launcher |
| 32 | def main [] { |
| 33 | print "Running tests..." |
| 34 | |
| 35 | let test_commands: list<string> = ( |
| 36 | scope commands |
| 37 | | where ($it.type == "custom") |
| 38 | and ($it.name | str starts-with "test ") |
| 39 | and not ($it.description | str starts-with "ignore") |
| 40 | | get name |
| 41 | ) |
| 42 | |
| 43 | let count_test_commands: int = ($test_commands | length) |
| 44 | let test_commands_together: string = ( |
| 45 | $test_commands |
| 46 | | enumerate |
| 47 | | each { |test| |
| 48 | [$"print '--> [($test.index + 1)/($count_test_commands)] ($test.item)'", $test.item] |
| 49 | } |
| 50 | | flatten |
| 51 | | str join ";" |
| 52 | ) |
| 53 | |
| 54 | nu --commands $"source `($env.CURRENT_FILE)`; ($test_commands_together)" |
| 55 | print $"\n✅ ALL TESTS COMPLETED SUCCESSFULLY" |
| 56 | } |
| 57 | |
| 58 | |
| 59 | # --- safe_name tests --- |
| 60 | |
| 61 | export def "test safe resource name" []: [ |
| 62 | nothing -> nothing |
| 63 | ] { |
| 64 | let actual: string = safe resource name "This is a_test w/special:characters." |
| 65 | let expected: string = "this-is-a-test-w-special-characters-" |
| 66 | assert equal $actual $expected |
| 67 | } |