You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
die "Problem iterating through test_semvers_copy (TEST SET #1). Encountered the same value twice in a row. prev_semver='$prev_semver' semver='$semver'.\n"
24
+
die "Problem iterating through test_cases (TEST SET #1). Encountered the same value twice in a row. prev_semver='$prev_semver' semver='$semver'.\n"
die "'nvm_get_node_from_pkg_json' POSITIVE test case failed (TEST SET #1). Expected '$expectedOutput' but got '$actual_output' when given input '$semver' and template '$template_file_name':\n$pkg_json_contents"
@@ -35,20 +38,23 @@ done
35
38
36
39
37
40
# (TEST SET #2) uses valid TEST_SEMVER's but invalid package.json templates
38
-
test_semvers_copy="$VALID_SEMVERS_FOR_PKG_JSON"
41
+
test_cases="$VALID_SEMVERS_FOR_PKG_JSON"
42
+
if [ -z"$test_cases" ];then
43
+
die 'TEST SET 2 for nvm_get_node_from_pkg_json given an empty set of test cases'
die "Problem iterating through test_semvers_copy (TEST SET #2). Encountered the same value twice in a row. prev_semver='$prev_semver' semver='$semver'.\n"
53
+
die "Problem iterating through test_cases (TEST SET #2). Encountered the same value twice in a row. prev_semver='$prev_semver' semver='$semver'.\n"
die "'nvm_get_node_from_pkg_json' NEGATIVE test case failed (TEST SET #2). Expected to get empty string but got '$actual_output' when given input template '$template_file_name':\n$pkg_json_contents"
@@ -58,20 +64,23 @@ done
58
64
59
65
60
66
# (TEST SET #3) uses invalid TEST_SEMVER's but valid package.json templates
61
-
test_semvers_copy="$INVALID_SEMVERS_FOR_PKG_JSON"
67
+
test_cases="$INVALID_SEMVERS_FOR_PKG_JSON"
68
+
if [ -z"$test_cases" ];then
69
+
die 'TEST SET 3 for nvm_get_node_from_pkg_json given an empty set of test cases'
die "Problem iterating through test_semvers_copy (TEST SET #3). Encountered the same value twice in a row. prev_semver='$prev_semver' semver='$semver'.\n"
79
+
die "Problem iterating through test_cases (TEST SET #3). Encountered the same value twice in a row. prev_semver='$prev_semver' semver='$semver'.\n"
die "'nvm_get_node_from_pkg_json' NEGATIVE test case failed (TEST SET #3). Expected to get empty string but got '$actual_output' when given input template '$template_file_name':\n$pkg_json_contents"
@@ -80,24 +89,28 @@ for template_file_name in package_json_templates/_valid_*; do
80
89
done
81
90
82
91
# (TEST SET #4) uses invalid TEST_SEMVER's and invalid package.json templates
83
-
test_semvers_copy="$INVALID_SEMVERS_FOR_PKG_JSON"
92
+
test_cases="$INVALID_SEMVERS_FOR_PKG_JSON"
93
+
if [ -z"$test_cases" ];then
94
+
die 'TEST SET 4 for nvm_get_node_from_pkg_json given an empty set of test cases'
die "Problem iterating through test_semvers_copy (TEST SET #4). Encountered the same value twice in a row. prev_semver='$prev_semver' semver='$semver'.\n"
104
+
die "Problem iterating through test_cases (TEST SET #4). Encountered the same value twice in a row. prev_semver='$prev_semver' semver='$semver'.\n"
die "'nvm_get_node_from_pkg_json' NEGATIVE test case failed (TEST SET #4). Expected to get empty string but got '$actual_output' when given input template '$template_file_name':\n$pkg_json_contents"
if [ -z"$input" ] || [ "$actual_output"!="$expected_output" ];then
51
-
die "nvm_normalize_semver test case failed. Expected output: '$expected_output'. Actual output: '$actual_output'. Input: '$input'.\n"
81
+
die "nvm_normalize_semver (TEST 3) test case failed. Expected output: '$expected_output'. Actual output: '$actual_output'. Input: '$input'.\n"
82
+
fi
83
+
test_cases=$(echo "$test_cases"| tail -n +2)
84
+
done
85
+
86
+
# TEST 4: Validate that invalid semvers with invalid characters that shouldn't be retrieved from the package.json produce no result from nvm_normalize_semver
87
+
test_cases="$INVALID_SEMVERS_FOR_PKG_JSON"
88
+
if [ -z"$test_cases" ];then
89
+
die 'nvm_normalize_semver (TEST 4) was given an empty set of test cases'
90
+
fi
91
+
while [ -n"$test_cases" ];do
92
+
semver=$(echo "$test_cases"| head -n1)
93
+
actual_output=$(nvm_normalize_semver "$semver")
94
+
if [ -z"$semver" ] || [ -n"$actual_output" ];then
95
+
die "nvm_normalize_semver (TEST 4) test case failed. Expected no output but got: '$actual_output'. Input: '$semver'.\n"
0 commit comments