-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #139 from larsewi/get-set-input
CFE-4070: Added commands `cfbs get-input` and `cfbs set-input`
- Loading branch information
Showing
4 changed files
with
293 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,163 @@ | ||
set -e | ||
set -x | ||
cd tests/ | ||
mkdir -p ./tmp/ | ||
cd ./tmp/ | ||
touch cfbs.json && rm cfbs.json | ||
rm -rf .git | ||
rm -rf create-single-file | ||
|
||
echo '{ | ||
"build": [ | ||
{ | ||
"name": "create-single-file", | ||
"input": [ | ||
{ | ||
"type": "string", | ||
"variable": "filename", | ||
"label": "Filename", | ||
"question": "What file should this module create?" | ||
} | ||
] | ||
} | ||
] | ||
}' > cfbs.json | ||
|
||
# Igor asks for input | ||
cfbs get-input create-single-file - > actual.output | ||
echo '[ | ||
{ | ||
"type": "string", | ||
"variable": "filename", | ||
"label": "Filename", | ||
"question": "What file should this module create?" | ||
} | ||
]' > expected.output | ||
diff actual.output expected.output | ||
|
||
# Igor adds response with some php magic | ||
echo '[ | ||
{ | ||
"type": "string", | ||
"variable": "filename", | ||
"label": "Filename", | ||
"question": "What file should this module create?", | ||
"response": "/tmp/test-1.txt" | ||
} | ||
]' | cfbs set-input create-single-file - | ||
|
||
# Igor asks for input again | ||
cfbs get-input create-single-file - > actual.output | ||
echo '[ | ||
{ | ||
"type": "string", | ||
"variable": "filename", | ||
"label": "Filename", | ||
"question": "What file should this module create?", | ||
"response": "/tmp/test-1.txt" | ||
} | ||
]' > expected.output | ||
diff actual.output expected.output | ||
|
||
# Igor changes the response to something else | ||
echo '[ | ||
{ | ||
"type": "string", | ||
"variable": "filename", | ||
"label": "Filename", | ||
"question": "What file should this module create?", | ||
"response": "/tmp/test-2.txt" | ||
} | ||
]' | cfbs set-input create-single-file - | ||
|
||
# Igor asks for input once again | ||
cfbs get-input create-single-file actual.output | ||
echo '[ | ||
{ | ||
"type": "string", | ||
"variable": "filename", | ||
"label": "Filename", | ||
"question": "What file should this module create?", | ||
"response": "/tmp/test-2.txt" | ||
} | ||
]' > expected.output | ||
diff actual.output expected.output | ||
|
||
# Igor changes the wrong value | ||
echo '[ | ||
{ | ||
"type": "string", | ||
"variable": "bogus", | ||
"label": "Filename", | ||
"question": "What file should this module create?", | ||
"response": "/tmp/test-2.txt" | ||
} | ||
]' > igors-input.json | ||
! cfbs set-input create-single-file igors-input.json | ||
|
||
# Now Igor instead changes a key | ||
echo '[ | ||
{ | ||
"doofus": "string", | ||
"variable": "filename", | ||
"label": "Filename", | ||
"question": "What file should this module create?", | ||
"response": "/tmp/test-2.txt" | ||
} | ||
]' > igors-input.json | ||
! cfbs set-input create-single-file igors-input.json | ||
|
||
# Igor changes the order but that's all right | ||
echo '[ | ||
{ | ||
"variable": "filename", | ||
"type": "string", | ||
"label": "Filename", | ||
"response": "/tmp/test-3.txt", | ||
"question": "What file should this module create?" | ||
} | ||
]' | cfbs set-input create-single-file - | ||
|
||
# Igor asks for input and now the order is different | ||
cfbs get-input create-single-file actual.output | ||
echo '[ | ||
{ | ||
"variable": "filename", | ||
"type": "string", | ||
"label": "Filename", | ||
"response": "/tmp/test-3.txt", | ||
"question": "What file should this module create?" | ||
} | ||
]' > expected.output | ||
diff actual.output expected.output | ||
|
||
# Igor asks for input of a module that is not in the project | ||
cfbs get-input delete-files@0.0.1 actual.output | ||
echo '[ | ||
{ | ||
"type": "list", | ||
"variable": "files", | ||
"namespace": "delete_files", | ||
"bundle": "delete_files", | ||
"label": "Files", | ||
"subtype": [ | ||
{ | ||
"key": "path", | ||
"type": "string", | ||
"label": "Path", | ||
"question": "Path to file" | ||
}, | ||
{ | ||
"key": "why", | ||
"type": "string", | ||
"label": "Why", | ||
"question": "Why should this file be deleted?", | ||
"default": "Unknown" | ||
} | ||
], | ||
"while": "Specify another file you want deleted on your hosts?" | ||
} | ||
]' > expected.output | ||
diff actual.output expected.output | ||
|
||
echo "Igor is happy!" |
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