Skip to content

Commit 2c37098

Browse files
committed
feat: add tests for Ruby ErrorEnums
- add new gem test-unit Signed-off-by: Jay <jaykumar20march@gmail.com>
1 parent 061fea8 commit 2c37098

File tree

3 files changed

+151
-1
lines changed

3 files changed

+151
-1
lines changed

src/SDK/Language/Ruby.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,11 @@ public function getFiles(): array
182182
'destination' => '/lib/{{ spec.title | caseDash }}/models/{{ definition.name | caseSnake }}.rb',
183183
'template' => 'ruby/lib/container/models/model.rb.twig',
184184
],
185+
[
186+
'scope' => 'default',
187+
'destination' => 'test/lib/{{ spec.title | caseDash }}/test_exception.rb',
188+
'template' => 'ruby/test/lib/appwrite/test_exception.rb.twig',
189+
],
185190
];
186191
}
187192

templates/ruby/Gemfile.twig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
source 'https://rubygems.org'
22

3-
gemspec
3+
gemspec
4+
gem 'test-unit'
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
require 'test/unit'
2+
require_relative '../../../lib/{{ spec.title | caseSnake }}/exception' # Ensure this path is correct
3+
4+
class ErrorTypeTest < Test::Unit::TestCase
5+
6+
def test_error_type_values
7+
assert_equal('general_mock', ErrorType::GeneralMock)
8+
assert_equal('general_argument_invalid', ErrorType::GeneralArgumentInvalid)
9+
assert_equal('general_query_limit_exceeded', ErrorType::GeneralQueryLimitExceeded)
10+
assert_equal('general_query_invalid', ErrorType::GeneralQueryInvalid)
11+
assert_equal('general_cursor_not_found', ErrorType::GeneralCursorNotFound)
12+
assert_equal('user_password_mismatch', ErrorType::UserPasswordMismatch)
13+
assert_equal('password_recently_used', ErrorType::PasswordRecentlyUsed)
14+
assert_equal('password_personal_data', ErrorType::PasswordPersonalData)
15+
assert_equal('user_phone_not_found', ErrorType::UserPhoneNotFound)
16+
assert_equal('user_missing_id', ErrorType::UserMissingId)
17+
assert_equal('user_oauth2_bad_request', ErrorType::UserOauth2BadRequest)
18+
assert_equal('storage_device_not_found', ErrorType::StorageDeviceNotFound)
19+
assert_equal('storage_file_empty', ErrorType::StorageFileEmpty)
20+
assert_equal('storage_file_type_unsupported', ErrorType::StorageFileTypeUnsupported)
21+
assert_equal('storage_invalid_file_size', ErrorType::StorageInvalidFileSize)
22+
assert_equal('storage_invalid_content_range', ErrorType::StorageInvalidContentRange)
23+
assert_equal('storage_invalid_appwrite_id', ErrorType::StorageInvalidAppwriteId)
24+
assert_equal('general_provider_failure', ErrorType::GeneralProviderFailure)
25+
assert_equal('build_not_ready', ErrorType::BuildNotReady)
26+
assert_equal('build_in_progress', ErrorType::BuildInProgress)
27+
assert_equal('collection_limit_exceeded', ErrorType::CollectionLimitExceeded)
28+
assert_equal('document_invalid_structure', ErrorType::DocumentInvalidStructure)
29+
assert_equal('document_missing_data', ErrorType::DocumentMissingData)
30+
assert_equal('document_missing_payload', ErrorType::DocumentMissingPayload)
31+
assert_equal('attribute_unknown', ErrorType::AttributeUnknown)
32+
assert_equal('attribute_not_available', ErrorType::AttributeNotAvailable)
33+
assert_equal('attribute_format_unsupported', ErrorType::AttributeFormatUnsupported)
34+
assert_equal('attribute_default_unsupported', ErrorType::AttributeDefaultUnsupported)
35+
assert_equal('attribute_limit_exceeded', ErrorType::AttributeLimitExceeded)
36+
assert_equal('attribute_value_invalid', ErrorType::AttributeValueInvalid)
37+
assert_equal('attribute_type_invalid', ErrorType::AttributeTypeInvalid)
38+
assert_equal('index_limit_exceeded', ErrorType::IndexLimitExceeded)
39+
assert_equal('index_invalid', ErrorType::IndexInvalid)
40+
assert_equal('project_unknown', ErrorType::ProjectUnknown)
41+
assert_equal('project_invalid_success_url', ErrorType::ProjectInvalidSuccessUrl)
42+
assert_equal('project_invalid_failure_url', ErrorType::ProjectInvalidFailureUrl)
43+
assert_equal('project_reserved_project', ErrorType::ProjectReservedProject)
44+
assert_equal('project_smtp_config_invalid', ErrorType::ProjectSmtpConfigInvalid)
45+
assert_equal('graphql_no_query', ErrorType::GraphqlNoQuery)
46+
assert_equal('graphql_too_many_queries', ErrorType::GraphqlTooManyQueries)
47+
assert_equal('general_access_forbidden', ErrorType::GeneralAccessForbidden)
48+
assert_equal('general_unauthorized_scope', ErrorType::GeneralUnauthorizedScope)
49+
assert_equal('user_jwt_invalid', ErrorType::UserJwtInvalid)
50+
assert_equal('user_blocked', ErrorType::UserBlocked)
51+
assert_equal('user_invalid_token', ErrorType::UserInvalidToken)
52+
assert_equal('user_email_not_whitelisted', ErrorType::UserEmailNotWhitelisted)
53+
assert_equal('user_invalid_code', ErrorType::UserInvalidCode)
54+
assert_equal('user_ip_not_whitelisted', ErrorType::UserIpNotWhitelisted)
55+
assert_equal('user_invalid_credentials', ErrorType::UserInvalidCredentials)
56+
assert_equal('user_anonymous_console_prohibited', ErrorType::UserAnonymousConsoleProhibited)
57+
assert_equal('user_session_already_exists', ErrorType::UserSessionAlreadyExists)
58+
assert_equal('user_unauthorized', ErrorType::UserUnauthorized)
59+
assert_equal('user_oauth2_unauthorized', ErrorType::UserOauth2Unauthorized)
60+
assert_equal('team_invalid_secret', ErrorType::TeamInvalidSecret)
61+
assert_equal('team_invite_mismatch', ErrorType::TeamInviteMismatch)
62+
assert_equal('project_key_expired', ErrorType::ProjectKeyExpired)
63+
assert_equal('rule_verification_failed', ErrorType::RuleVerificationFailed)
64+
assert_equal('project_template_default_deletion', ErrorType::ProjectTemplateDefaultDeletion)
65+
assert_equal('general_unknown_origin', ErrorType::GeneralUnknownOrigin)
66+
assert_equal('storage_invalid_file', ErrorType::StorageInvalidFile)
67+
assert_equal('document_delete_restricted', ErrorType::DocumentDeleteRestricted)
68+
assert_equal('general_route_not_found', ErrorType::GeneralRouteNotFound)
69+
assert_equal('user_not_found', ErrorType::UserNotFound)
70+
assert_equal('user_session_not_found', ErrorType::UserSessionNotFound)
71+
assert_equal('user_identity_not_found', ErrorType::UserIdentityNotFound)
72+
assert_equal('team_not_found', ErrorType::TeamNotFound)
73+
assert_equal('team_invite_not_found', ErrorType::TeamInviteNotFound)
74+
assert_equal('team_membership_mismatch', ErrorType::TeamMembershipMismatch)
75+
assert_equal('membership_not_found', ErrorType::MembershipNotFound)
76+
assert_equal('avatar_set_not_found', ErrorType::AvatarSetNotFound)
77+
assert_equal('avatar_not_found', ErrorType::AvatarNotFound)
78+
assert_equal('avatar_image_not_found', ErrorType::AvatarImageNotFound)
79+
assert_equal('avatar_remote_url_failed', ErrorType::AvatarRemoteUrlFailed)
80+
assert_equal('avatar_icon_not_found', ErrorType::AvatarIconNotFound)
81+
assert_equal('storage_file_not_found', ErrorType::StorageFileNotFound)
82+
assert_equal('storage_bucket_not_found', ErrorType::StorageBucketNotFound)
83+
assert_equal('installation_not_found', ErrorType::InstallationNotFound)
84+
assert_equal('provider_repository_not_found', ErrorType::ProviderRepositoryNotFound)
85+
assert_equal('repository_not_found', ErrorType::RepositoryNotFound)
86+
assert_equal('function_not_found', ErrorType::FunctionNotFound)
87+
assert_equal('function_runtime_unsupported', ErrorType::FunctionRuntimeUnsupported)
88+
assert_equal('build_not_found', ErrorType::BuildNotFound)
89+
assert_equal('deployment_not_found', ErrorType::DeploymentNotFound)
90+
assert_equal('execution_not_found', ErrorType::ExecutionNotFound)
91+
assert_equal('database_not_found', ErrorType::DatabaseNotFound)
92+
assert_equal('collection_not_found', ErrorType::CollectionNotFound)
93+
assert_equal('document_not_found', ErrorType::DocumentNotFound)
94+
assert_equal('attribute_not_found', ErrorType::AttributeNotFound)
95+
assert_equal('index_not_found', ErrorType::IndexNotFound)
96+
assert_equal('project_not_found', ErrorType::ProjectNotFound)
97+
assert_equal('router_host_not_found', ErrorType::RouterHostNotFound)
98+
assert_equal('rule_resource_not_found', ErrorType::RuleResourceNotFound)
99+
assert_equal('rule_not_found', ErrorType::RuleNotFound)
100+
assert_equal('webhook_not_found', ErrorType::WebhookNotFound)
101+
assert_equal('key_not_found', ErrorType::KeyNotFound)
102+
assert_equal('platform_not_found', ErrorType::PlatformNotFound)
103+
assert_equal('variable_not_found', ErrorType::VariableNotFound)
104+
assert_equal('migration_not_found', ErrorType::MigrationNotFound)
105+
assert_equal('general_not_implemented', ErrorType::GeneralNotImplemented)
106+
assert_equal('user_already_exists', ErrorType::UserAlreadyExists)
107+
assert_equal('user_email_already_exists', ErrorType::UserEmailAlreadyExists)
108+
assert_equal('user_phone_already_exists', ErrorType::UserPhoneAlreadyExists)
109+
assert_equal('team_invite_already_exists', ErrorType::TeamInviteAlreadyExists)
110+
assert_equal('team_already_exists', ErrorType::TeamAlreadyExists)
111+
assert_equal('membership_already_confirmed', ErrorType::MembershipAlreadyConfirmed)
112+
assert_equal('storage_file_already_exists', ErrorType::StorageFileAlreadyExists)
113+
assert_equal('storage_bucket_already_exists', ErrorType::StorageBucketAlreadyExists)
114+
assert_equal('provider_contribution_conflict', ErrorType::ProviderContributionConflict)
115+
assert_equal('database_already_exists', ErrorType::DatabaseAlreadyExists)
116+
assert_equal('collection_already_exists', ErrorType::CollectionAlreadyExists)
117+
assert_equal('document_already_exists', ErrorType::DocumentAlreadyExists)
118+
assert_equal('document_update_conflict', ErrorType::DocumentUpdateConflict)
119+
assert_equal('attribute_already_exists', ErrorType::AttributeAlreadyExists)
120+
assert_equal('index_already_exists', ErrorType::IndexAlreadyExists)
121+
assert_equal('project_already_exists', ErrorType::ProjectAlreadyExists)
122+
assert_equal('rule_already_exists', ErrorType::RuleAlreadyExists)
123+
assert_equal('variable_already_exists', ErrorType::VariableAlreadyExists)
124+
assert_equal('migration_already_exists', ErrorType::MigrationAlreadyExists)
125+
assert_equal('migration_in_progress', ErrorType::MigrationInProgress)
126+
assert_equal('user_password_reset_required', ErrorType::UserPasswordResetRequired)
127+
assert_equal('project_provider_disabled', ErrorType::ProjectProviderDisabled)
128+
assert_equal('storage_invalid_range', ErrorType::StorageInvalidRange)
129+
assert_equal('user_oauth2_provider_error', ErrorType::UserOAuth2ProviderError)
130+
assert_equal('general_rate_limit_exceeded', ErrorType::GeneralRateLimitExceeded)
131+
assert_equal('general_unknown', ErrorType::GeneralUnknown)
132+
assert_equal('general_server_error', ErrorType::GeneralServerError)
133+
assert_equal('general_protocol_unsupported', ErrorType::GeneralProtocolUnsupported)
134+
assert_equal('general_codes_disabled', ErrorType::GeneralCodesDisabled)
135+
assert_equal('router_domain_not_configured', ErrorType::RouterDomainNotConfigured)
136+
assert_equal('general_usage_disabled', ErrorType::GeneralUsageDisabled)
137+
assert_equal('user_count_exceeded', ErrorType::UserCountExceeded)
138+
assert_equal('user_auth_method_unsupported', ErrorType::UserAuthMethodUnsupported)
139+
assert_equal('project_provider_unsupported', ErrorType::ProjectProviderUnsupported)
140+
assert_equal('general_service_disabled', ErrorType::GeneralServiceDisabled)
141+
assert_equal('general_smtp_disabled', ErrorType::GeneralSMTPDisabled)
142+
assert_equal('general_phone_disabled', ErrorType::GeneralPhoneDisabled)
143+
end
144+
end

0 commit comments

Comments
 (0)