@@ -57,7 +57,22 @@ subroutine collect_package_dependencies(tests)
57
57
& new_unittest(" version-found-in-cache" , version_found_in_cache), &
58
58
& new_unittest(" no-version-in-default-cache" , no_version_in_default_cache), &
59
59
& new_unittest(" no-version-in-cache-or-registry" , no_version_in_cache_or_registry, should_fail= .true. ), &
60
- & new_unittest(" other-versions-in-default-cache" , other_versions_in_default_cache) &
60
+ & new_unittest(" other-versions-in-default-cache" , other_versions_in_default_cache), &
61
+ & new_unittest(" pkg-data-no-code" , pkg_data_no_code, should_fail= .true. ), &
62
+ & new_unittest(" pkg-data-corrupt-code" , pkg_data_corrupt_code, should_fail= .true. ), &
63
+ & new_unittest(" pkg-data-missing-error-message" , pkg_data_missing_error_msg, should_fail= .true. ), &
64
+ & new_unittest(" pkg-data-error-reading-message" , pkg_data_error_reading_msg, should_fail= .true. ), &
65
+ & new_unittest(" pkg-data-error-has-message" , pkg_data_error_has_msg, should_fail= .true. ), &
66
+ & new_unittest(" pkg-data-error-no-data" , pkg_data_no_data, should_fail= .true. ), &
67
+ & new_unittest(" pkg-data-error-reading-data" , pkg_data_error_reading_data, should_fail= .true. ), &
68
+ & new_unittest(" pkg-data-requested-version-wrong-key" , pkg_data_requested_version_wrong_key, should_fail= .true. ), &
69
+ & new_unittest(" pkg-data-no-version-requested-wrong-key" , pkg_data_no_version_requested_wrong_key, should_fail= .true. ), &
70
+ & new_unittest(" pkg-data-error-reading-latest-version" , pkg_data_error_reading_latest_version, should_fail= .true. ), &
71
+ & new_unittest(" pkg-data-no-download-url" , pkg_data_no_download_url, should_fail= .true. ), &
72
+ & new_unittest(" pkg-data-error-reading-donwload-url" , pkg_data_error_reading_download_url, should_fail= .true. ), &
73
+ & new_unittest(" pkg-data-no-version" , pkg_data_no_version, should_fail= .true. ), &
74
+ & new_unittest(" pkg-data-error-reading-version" , pkg_data_error_reading_version, should_fail= .true. ), &
75
+ & new_unittest(" pkg-data-invalid-version" , pkg_data_invalid_version, should_fail= .true. ) &
61
76
& ]
62
77
63
78
end subroutine collect_package_dependencies
@@ -920,6 +935,249 @@ subroutine other_versions_in_default_cache(error)
920
935
921
936
end subroutine other_versions_in_default_cache
922
937
938
+ ! > Package data returned from the registry does not contain a code field.
939
+ subroutine pkg_data_no_code (error )
940
+ type (error_t), allocatable , intent (out ) :: error
941
+
942
+ type (dependency_node_t) :: node
943
+ character (:), allocatable :: url
944
+ type (version_t) :: version
945
+ type (json_object) :: json
946
+ class(json_value), allocatable :: j_value
947
+
948
+ call json_loads(j_value, ' {}' )
949
+ json = cast_to_object(j_value)
950
+
951
+ call check_and_read_pkg_data(json, node, url, version, error)
952
+
953
+ end subroutine pkg_data_no_code
954
+
955
+ ! > Error reading status code from package data.
956
+ subroutine pkg_data_corrupt_code (error )
957
+ type (error_t), allocatable , intent (out ) :: error
958
+
959
+ type (dependency_node_t) :: node
960
+ character (:), allocatable :: url
961
+ type (version_t) :: version
962
+ type (json_object) :: json
963
+ class(json_value), allocatable :: j_value
964
+
965
+ call json_loads(j_value, ' {"code": "integer expected"}' )
966
+ json = cast_to_object(j_value)
967
+
968
+ call check_and_read_pkg_data(json, node, url, version, error)
969
+
970
+ end subroutine pkg_data_corrupt_code
971
+
972
+ subroutine pkg_data_missing_error_msg (error )
973
+ type (error_t), allocatable , intent (out ) :: error
974
+
975
+ type (dependency_node_t) :: node
976
+ character (:), allocatable :: url
977
+ type (version_t) :: version
978
+ type (json_object) :: json
979
+ class(json_value), allocatable :: j_value
980
+
981
+ call json_loads(j_value, ' {"code": 123}' )
982
+ json = cast_to_object(j_value)
983
+
984
+ call check_and_read_pkg_data(json, node, url, version, error)
985
+
986
+ end subroutine pkg_data_missing_error_msg
987
+
988
+ subroutine pkg_data_error_reading_msg (error )
989
+ type (error_t), allocatable , intent (out ) :: error
990
+
991
+ type (dependency_node_t) :: node
992
+ character (:), allocatable :: url
993
+ type (version_t) :: version
994
+ type (json_object) :: json
995
+ class(json_value), allocatable :: j_value
996
+
997
+ call json_loads(j_value, ' {"code": 123, "message": 123}' )
998
+ json = cast_to_object(j_value)
999
+
1000
+ call check_and_read_pkg_data(json, node, url, version, error)
1001
+
1002
+ end subroutine pkg_data_error_reading_msg
1003
+
1004
+ subroutine pkg_data_error_has_msg (error )
1005
+ type (error_t), allocatable , intent (out ) :: error
1006
+
1007
+ type (dependency_node_t) :: node
1008
+ character (:), allocatable :: url
1009
+ type (version_t) :: version
1010
+ type (json_object) :: json
1011
+ class(json_value), allocatable :: j_value
1012
+
1013
+ call json_loads(j_value, ' {"code": 123, "message": "Really bad error message"}' )
1014
+ json = cast_to_object(j_value)
1015
+
1016
+ call check_and_read_pkg_data(json, node, url, version, error)
1017
+
1018
+ end subroutine pkg_data_error_has_msg
1019
+
1020
+ subroutine pkg_data_no_data (error )
1021
+ type (error_t), allocatable , intent (out ) :: error
1022
+
1023
+ type (dependency_node_t) :: node
1024
+ character (:), allocatable :: url
1025
+ type (version_t) :: version
1026
+ type (json_object) :: json
1027
+ class(json_value), allocatable :: j_value
1028
+
1029
+ call json_loads(j_value, ' {"code": 200}' )
1030
+ json = cast_to_object(j_value)
1031
+
1032
+ call check_and_read_pkg_data(json, node, url, version, error)
1033
+
1034
+ end subroutine pkg_data_no_data
1035
+
1036
+ subroutine pkg_data_error_reading_data (error )
1037
+ type (error_t), allocatable , intent (out ) :: error
1038
+
1039
+ type (dependency_node_t) :: node
1040
+ character (:), allocatable :: url
1041
+ type (version_t) :: version
1042
+ type (json_object) :: json
1043
+ class(json_value), allocatable :: j_value
1044
+
1045
+ call json_loads(j_value, ' {"code": 200, "data": 123}' )
1046
+ json = cast_to_object(j_value)
1047
+
1048
+ call check_and_read_pkg_data(json, node, url, version, error)
1049
+
1050
+ end subroutine pkg_data_error_reading_data
1051
+
1052
+ subroutine pkg_data_requested_version_wrong_key (error )
1053
+ type (error_t), allocatable , intent (out ) :: error
1054
+
1055
+ type (dependency_node_t) :: node
1056
+ character (:), allocatable :: url
1057
+ type (version_t) :: version
1058
+ type (json_object) :: json
1059
+ class(json_value), allocatable :: j_value
1060
+
1061
+ allocate (node% requested_version)
1062
+ call json_loads(j_value, ' {"code": 200, "data": {"latest_version_data": 123}}' ) ! Expected key: "version_data"
1063
+ json = cast_to_object(j_value)
1064
+
1065
+ call check_and_read_pkg_data(json, node, url, version, error)
1066
+
1067
+ end subroutine pkg_data_requested_version_wrong_key
1068
+
1069
+ subroutine pkg_data_no_version_requested_wrong_key (error )
1070
+ type (error_t), allocatable , intent (out ) :: error
1071
+
1072
+ type (dependency_node_t) :: node
1073
+ character (:), allocatable :: url
1074
+ type (version_t) :: version
1075
+ type (json_object) :: json
1076
+ class(json_value), allocatable :: j_value
1077
+
1078
+ call json_loads(j_value, ' {"code": 200, "data": {"version_data": 123}}' ) ! Expected key: "latest_version_data"
1079
+ json = cast_to_object(j_value)
1080
+
1081
+ call check_and_read_pkg_data(json, node, url, version, error)
1082
+
1083
+ end subroutine pkg_data_no_version_requested_wrong_key
1084
+
1085
+ subroutine pkg_data_error_reading_latest_version (error )
1086
+ type (error_t), allocatable , intent (out ) :: error
1087
+
1088
+ type (dependency_node_t) :: node
1089
+ character (:), allocatable :: url
1090
+ type (version_t) :: version
1091
+ type (json_object) :: json
1092
+ class(json_value), allocatable :: j_value
1093
+
1094
+ call json_loads(j_value, ' {"code": 200, "data": {"latest_version_data": 123}}' )
1095
+ json = cast_to_object(j_value)
1096
+
1097
+ call check_and_read_pkg_data(json, node, url, version, error)
1098
+
1099
+ end subroutine pkg_data_error_reading_latest_version
1100
+
1101
+ subroutine pkg_data_no_download_url (error )
1102
+ type (error_t), allocatable , intent (out ) :: error
1103
+
1104
+ type (dependency_node_t) :: node
1105
+ character (:), allocatable :: url
1106
+ type (version_t) :: version
1107
+ type (json_object) :: json
1108
+ class(json_value), allocatable :: j_value
1109
+
1110
+ call json_loads(j_value, ' {"code": 200, "data": {"latest_version_data": {}}}' )
1111
+ json = cast_to_object(j_value)
1112
+
1113
+ call check_and_read_pkg_data(json, node, url, version, error)
1114
+
1115
+ end subroutine pkg_data_no_download_url
1116
+
1117
+ subroutine pkg_data_error_reading_download_url (error )
1118
+ type (error_t), allocatable , intent (out ) :: error
1119
+
1120
+ type (dependency_node_t) :: node
1121
+ character (:), allocatable :: url
1122
+ type (version_t) :: version
1123
+ type (json_object) :: json
1124
+ class(json_value), allocatable :: j_value
1125
+
1126
+ call json_loads(j_value, ' {"code": 200, "data": {"latest_version_data": {"download_url": 123}}}' )
1127
+ json = cast_to_object(j_value)
1128
+
1129
+ call check_and_read_pkg_data(json, node, url, version, error)
1130
+
1131
+ end subroutine pkg_data_error_reading_download_url
1132
+
1133
+ subroutine pkg_data_no_version (error )
1134
+ type (error_t), allocatable , intent (out ) :: error
1135
+
1136
+ type (dependency_node_t) :: node
1137
+ character (:), allocatable :: url
1138
+ type (version_t) :: version
1139
+ type (json_object) :: json
1140
+ class(json_value), allocatable :: j_value
1141
+
1142
+ call json_loads(j_value, ' {"code": 200, "data": {"latest_version_data": {"download_url": "abc"}}}' )
1143
+ json = cast_to_object(j_value)
1144
+
1145
+ call check_and_read_pkg_data(json, node, url, version, error)
1146
+
1147
+ end subroutine pkg_data_no_version
1148
+
1149
+ subroutine pkg_data_error_reading_version (error )
1150
+ type (error_t), allocatable , intent (out ) :: error
1151
+
1152
+ type (dependency_node_t) :: node
1153
+ character (:), allocatable :: url
1154
+ type (version_t) :: version
1155
+ type (json_object) :: json
1156
+ class(json_value), allocatable :: j_value
1157
+
1158
+ call json_loads(j_value, ' {"code": 200, "data": {"latest_version_data": {"download_url": "abc", "version": 123}}}' )
1159
+ json = cast_to_object(j_value)
1160
+
1161
+ call check_and_read_pkg_data(json, node, url, version, error)
1162
+
1163
+ end subroutine pkg_data_error_reading_version
1164
+
1165
+ subroutine pkg_data_invalid_version (error )
1166
+ type (error_t), allocatable , intent (out ) :: error
1167
+
1168
+ type (dependency_node_t) :: node
1169
+ character (:), allocatable :: url
1170
+ type (version_t) :: version
1171
+ type (json_object) :: json
1172
+ class(json_value), allocatable :: j_value
1173
+
1174
+ call json_loads(j_value, ' {"code": 200, "data": {"latest_version_data": {"download_url": "abc", "version": "abc"}}}' )
1175
+ json = cast_to_object(j_value)
1176
+
1177
+ call check_and_read_pkg_data(json, node, url, version, error)
1178
+
1179
+ end subroutine pkg_data_invalid_version
1180
+
923
1181
! > Resolve a single dependency node
924
1182
subroutine resolve_dependency_once (self , dependency , root , error )
925
1183
! > Mock instance of the dependency tree
0 commit comments