|
| 1 | +#!/usr/bin/env sh |
| 2 | +# |
| 3 | +# MIT License |
| 4 | +# |
| 5 | +# (C) Copyright 2025 Hewlett Packard Enterprise Development LP |
| 6 | +# |
| 7 | +# Permission is hereby granted, free of charge, to any person obtaining a |
| 8 | +# copy of this software and associated documentation files (the "Software"), |
| 9 | +# to deal in the Software without restriction, including without limitation |
| 10 | +# the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 11 | +# and/or sell copies of the Software, and to permit persons to whom the |
| 12 | +# Software is furnished to do so, subject to the following conditions: |
| 13 | +# |
| 14 | +# The above copyright notice and this permission notice shall be included |
| 15 | +# in all copies or substantial portions of the Software. |
| 16 | +# |
| 17 | +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 18 | +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 19 | +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 20 | +# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR |
| 21 | +# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| 22 | +# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 23 | +# OTHER DEALINGS IN THE SOFTWARE. |
| 24 | +# |
| 25 | + |
| 26 | +# ── add command ───────────────────────────────────────────────────── |
| 27 | + |
| 28 | +Describe 'cani ochami tests' |
| 29 | + |
| 30 | + # ── help & flags ──────────────────────────────────────────────── |
| 31 | + |
| 32 | + Describe 'base command' |
| 33 | + It 'exits 0 and shows help message' |
| 34 | + When call bin/cani alpha import ochami |
| 35 | + The status should equal 0 |
| 36 | + End |
| 37 | + End |
| 38 | + |
| 39 | + Describe 'import empty' |
| 40 | + It 'exits 0 and shows import completed successfully' |
| 41 | + When call bin/cani --datastore-path /tmp/tmpcanidb.json alpha import ochami -f testdata/fixtures/ochami/empty.json |
| 42 | + The status should equal 0 |
| 43 | + The stderr should include 'No valid records found in JSON' |
| 44 | + The stderr should include 'Import completed successfully using provider ochami' |
| 45 | + End |
| 46 | + |
| 47 | + It 'exits 1 and shows no such file or directory' |
| 48 | + When call bin/cani --datastore-path /tmp/tmpcanidb.json alpha import ochami -f badpath |
| 49 | + The status should equal 1 |
| 50 | + The stderr should include 'no such file or directory' |
| 51 | + End |
| 52 | + End |
| 53 | + |
| 54 | + |
| 55 | + Describe 'import inventory' |
| 56 | + It 'calls the basic inventory import' |
| 57 | + When call bin/cani --datastore-path /tmp/tmpcanidb.json alpha import ochami -f testdata/fixtures/ochami/upload_request.json |
| 58 | + The status should equal 0 |
| 59 | + The stderr should include '0 racks' |
| 60 | + The stderr should include '3 devices' |
| 61 | + The stderr should include '0 cables' |
| 62 | + The stderr should include 'Import completed successfully using provider ochami' |
| 63 | + End |
| 64 | + End |
| 65 | +End |
| 66 | + |
0 commit comments