Skip to content

Commit 33fe9cf

Browse files
committed
update: update test generator's data source.
Signed-off-by: Jay <jaykumar20march@gmail.com>
1 parent 3f3afb0 commit 33fe9cf

File tree

25 files changed

+48
-187
lines changed

25 files changed

+48
-187
lines changed

src/SDK/SDK.php

Lines changed: 1 addition & 140 deletions
Original file line numberDiff line numberDiff line change
@@ -69,144 +69,6 @@ class SDK
6969
'examples' => '',
7070
'test' => 'false'
7171
];
72-
private array $errorTypes = [
73-
'GeneralMock' => 'general_mock',
74-
'GeneralArgumentInvalid' => 'general_argument_invalid',
75-
'GeneralQueryLimitExceeded' => 'general_query_limit_exceeded',
76-
'GeneralQueryInvalid' => 'general_query_invalid',
77-
'GeneralCursorNotFound' => 'general_cursor_not_found',
78-
'UserPasswordMismatch' => 'user_password_mismatch',
79-
'PasswordRecentlyUsed' => 'password_recently_used',
80-
'PasswordPersonalData' => 'password_personal_data',
81-
'UserPhoneNotFound' => 'user_phone_not_found',
82-
'UserMissingId' => 'user_missing_id',
83-
'UserOauth2BadRequest' => 'user_oauth2_bad_request',
84-
'StorageDeviceNotFound' => 'storage_device_not_found',
85-
'StorageFileEmpty' => 'storage_file_empty',
86-
'StorageFileTypeUnsupported' => 'storage_file_type_unsupported',
87-
'StorageInvalidFileSize' => 'storage_invalid_file_size',
88-
'StorageInvalidContentRange' => 'storage_invalid_content_range',
89-
'StorageInvalidAppwriteId' => 'storage_invalid_appwrite_id',
90-
'GeneralProviderFailure' => 'general_provider_failure',
91-
'BuildNotReady' => 'build_not_ready',
92-
'BuildInProgress' => 'build_in_progress',
93-
'CollectionLimitExceeded' => 'collection_limit_exceeded',
94-
'DocumentInvalidStructure' => 'document_invalid_structure',
95-
'DocumentMissingData' => 'document_missing_data',
96-
'DocumentMissingPayload' => 'document_missing_payload',
97-
'AttributeUnknown' => 'attribute_unknown',
98-
'AttributeNotAvailable' => 'attribute_not_available',
99-
'AttributeFormatUnsupported' => 'attribute_format_unsupported',
100-
'AttributeDefaultUnsupported' => 'attribute_default_unsupported',
101-
'AttributeLimitExceeded' => 'attribute_limit_exceeded',
102-
'AttributeValueInvalid' => 'attribute_value_invalid',
103-
'AttributeTypeInvalid' => 'attribute_type_invalid',
104-
'IndexLimitExceeded' => 'index_limit_exceeded',
105-
'IndexInvalid' => 'index_invalid',
106-
'ProjectUnknown' => 'project_unknown',
107-
'ProjectInvalidSuccessUrl' => 'project_invalid_success_url',
108-
'ProjectInvalidFailureUrl' => 'project_invalid_failure_url',
109-
'ProjectReservedProject' => 'project_reserved_project',
110-
'ProjectSmtpConfigInvalid' => 'project_smtp_config_invalid',
111-
'GraphqlNoQuery' => 'graphql_no_query',
112-
'GraphqlTooManyQueries' => 'graphql_too_many_queries',
113-
'GeneralAccessForbidden' => 'general_access_forbidden',
114-
'GeneralUnauthorizedScope' => 'general_unauthorized_scope',
115-
'UserJwtInvalid' => 'user_jwt_invalid',
116-
'UserBlocked' => 'user_blocked',
117-
'UserInvalidToken' => 'user_invalid_token',
118-
'UserEmailNotWhitelisted' => 'user_email_not_whitelisted',
119-
'UserInvalidCode' => 'user_invalid_code',
120-
'UserIpNotWhitelisted' => 'user_ip_not_whitelisted',
121-
'UserInvalidCredentials' => 'user_invalid_credentials',
122-
'UserAnonymousConsoleProhibited' => 'user_anonymous_console_prohibited',
123-
'UserSessionAlreadyExists' => 'user_session_already_exists',
124-
'UserUnauthorized' => 'user_unauthorized',
125-
'UserOauth2Unauthorized' => 'user_oauth2_unauthorized',
126-
'TeamInvalidSecret' => 'team_invalid_secret',
127-
'TeamInviteMismatch' => 'team_invite_mismatch',
128-
'ProjectKeyExpired' => 'project_key_expired',
129-
'RuleVerificationFailed' => 'rule_verification_failed',
130-
'ProjectTemplateDefaultDeletion' => 'project_template_default_deletion',
131-
'GeneralUnknownOrigin' => 'general_unknown_origin',
132-
'StorageInvalidFile' => 'storage_invalid_file',
133-
'DocumentDeleteRestricted' => 'document_delete_restricted',
134-
'GeneralRouteNotFound' => 'general_route_not_found',
135-
'UserNotFound' => 'user_not_found',
136-
'UserSessionNotFound' => 'user_session_not_found',
137-
'UserIdentityNotFound' => 'user_identity_not_found',
138-
'TeamNotFound' => 'team_not_found',
139-
'TeamInviteNotFound' => 'team_invite_not_found',
140-
'TeamMembershipMismatch' => 'team_membership_mismatch',
141-
'MembershipNotFound' => 'membership_not_found',
142-
'AvatarSetNotFound' => 'avatar_set_not_found',
143-
'AvatarNotFound' => 'avatar_not_found',
144-
'AvatarImageNotFound' => 'avatar_image_not_found',
145-
'AvatarRemoteUrlFailed' => 'avatar_remote_url_failed',
146-
'AvatarIconNotFound' => 'avatar_icon_not_found',
147-
'StorageFileNotFound' => 'storage_file_not_found',
148-
'StorageBucketNotFound' => 'storage_bucket_not_found',
149-
'InstallationNotFound' => 'installation_not_found',
150-
'ProviderRepositoryNotFound' => 'provider_repository_not_found',
151-
'RepositoryNotFound' => 'repository_not_found',
152-
'FunctionNotFound' => 'function_not_found',
153-
'FunctionRuntimeUnsupported' => 'function_runtime_unsupported',
154-
'BuildNotFound' => 'build_not_found',
155-
'DeploymentNotFound' => 'deployment_not_found',
156-
'ExecutionNotFound' => 'execution_not_found',
157-
'DatabaseNotFound' => 'database_not_found',
158-
'CollectionNotFound' => 'collection_not_found',
159-
'DocumentNotFound' => 'document_not_found',
160-
'AttributeNotFound' => 'attribute_not_found',
161-
'IndexNotFound' => 'index_not_found',
162-
'ProjectNotFound' => 'project_not_found',
163-
'RouterHostNotFound' => 'router_host_not_found',
164-
'RuleResourceNotFound' => 'rule_resource_not_found',
165-
'RuleNotFound' => 'rule_not_found',
166-
'WebhookNotFound' => 'webhook_not_found',
167-
'KeyNotFound' => 'key_not_found',
168-
'PlatformNotFound' => 'platform_not_found',
169-
'VariableNotFound' => 'variable_not_found',
170-
'MigrationNotFound' => 'migration_not_found',
171-
'GeneralNotImplemented' => 'general_not_implemented',
172-
'UserAlreadyExists' => 'user_already_exists',
173-
'UserEmailAlreadyExists' => 'user_email_already_exists',
174-
'UserPhoneAlreadyExists' => 'user_phone_already_exists',
175-
'TeamInviteAlreadyExists' => 'team_invite_already_exists',
176-
'TeamAlreadyExists' => 'team_already_exists',
177-
'MembershipAlreadyConfirmed' => 'membership_already_confirmed',
178-
'StorageFileAlreadyExists' => 'storage_file_already_exists',
179-
'StorageBucketAlreadyExists' => 'storage_bucket_already_exists',
180-
'ProviderContributionConflict' => 'provider_contribution_conflict',
181-
'DatabaseAlreadyExists' => 'database_already_exists',
182-
'CollectionAlreadyExists' => 'collection_already_exists',
183-
'DocumentAlreadyExists' => 'document_already_exists',
184-
'DocumentUpdateConflict' => 'document_update_conflict',
185-
'AttributeAlreadyExists' => 'attribute_already_exists',
186-
'IndexAlreadyExists' => 'index_already_exists',
187-
'ProjectAlreadyExists' => 'project_already_exists',
188-
'RuleAlreadyExists' => 'rule_already_exists',
189-
'VariableAlreadyExists' => 'variable_already_exists',
190-
'MigrationAlreadyExists' => 'migration_already_exists',
191-
'MigrationInProgress' => 'migration_in_progress',
192-
'UserPasswordResetRequired' => 'user_password_reset_required',
193-
'ProjectProviderDisabled' => 'project_provider_disabled',
194-
'StorageInvalidRange' => 'storage_invalid_range',
195-
'UserOAuth2ProviderError' => 'user_oauth2_provider_error',
196-
'GeneralRateLimitExceeded' => 'general_rate_limit_exceeded',
197-
'GeneralUnknown' => 'general_unknown',
198-
'GeneralServerError' => 'general_server_error',
199-
'GeneralProtocolUnsupported' => 'general_protocol_unsupported',
200-
'GeneralCodesDisabled' => 'general_codes_disabled',
201-
'RouterDomainNotConfigured' => 'router_domain_not_configured',
202-
'GeneralUsageDisabled' => 'general_usage_disabled',
203-
'UserCountExceeded' => 'user_count_exceeded',
204-
'UserAuthMethodUnsupported' => 'user_auth_method_unsupported',
205-
'ProjectProviderUnsupported' => 'project_provider_unsupported',
206-
'GeneralServiceDisabled' => 'general_service_disabled',
207-
'GeneralSMTPDisabled' => 'general_smtp_disabled',
208-
'GeneralPhoneDisabled' => 'general_phone_disabled'
209-
];
21072

21173
/**
21274
* SDK constructor.
@@ -693,8 +555,7 @@ public function generate(string $target): void
693555
'name' => $this->language->getName(),
694556
'params' => $this->language->getParams(),
695557
],
696-
'sdk' => $this->getParams(),
697-
'testData' => ['enumData' => $this->errorTypes]
558+
'sdk' => $this->getParams()
698559
];
699560

700561
foreach ($this->language->getFiles() as $file) {

src/Spec/Swagger2.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ public function getDefinitions()
312312
"name" => $key,
313313
"properties" => $schema['properties'] ?? [],
314314
"description" => $schema['description'] ?? [],
315-
"error_types" => $schema['x-appwrite']['types'] ?? null,
315+
"errorTypes" => $schema['x-appwrite']['types'] ?? null,
316316
"required" => $schema['required'] ?? [],
317317
"additionalProperties" => $schema['additionalProperties'] ?? []
318318
];
@@ -345,7 +345,7 @@ public function getDefinitions()
345345
$types[] = [
346346
'code' => $type['code'],
347347
'type' => $type['type'],
348-
'description' => $type['description']
348+
'message' => $type['message']
349349
];
350350
}
351351
$sch['errorTypes'] = $types;

templates/android/library/src/main/java/io/appwrite/exceptions/Exception.kt.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ class {{spec.title | caseUcfirst}} Exception(
1010
) : Exception(message)
1111

1212
enum class ErrorType(val value: String) {
13-
{% for error in spec.definitions.appwriteException.error_types %}
13+
{% for error in spec.definitions.appwriteException.errorTypes %}
1414
/**
15-
* {{ error.description }}
15+
* {{ error.message }}
1616
*/
1717
{{ error.type|title|replace({'_': ''}) }}("{{ error.type }}"),
1818
{% endfor %}

templates/android/tests/TestException.kt.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ class TestException {
88

99
@Test
1010
fun testEnumValues() {
11-
{% for key, value in testData.enumData %}
12-
assertEquals(ErrorType.{{ key }}.value), "{{ value }}")
11+
{% for error in spec.definitions.appwriteException.errorTypes %}
12+
assertEquals(ErrorType.{{ error.type|title|replace({'_': ''}) }}.value), "{{ error.type }}")
1313
{% endfor %}
1414
}
1515
}

templates/dart/lib/src/exception.dart.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ class {{spec.title | caseUcfirst}}Exception implements Exception {
2323
}
2424

2525
enum ErrorType {
26-
{% for error in spec.definitions.appwriteException.error_types %}
27-
/// {{ error.description }}
26+
{% for error in spec.definitions.appwriteException.errorTypes %}
27+
/// {{ error.message }}
2828
{{ error.type|title|replace({'_': ''}) }},
2929
{% endfor %}
3030
}

templates/dart/test/src/exception_test.dart.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ void main() {
2222
group('ErrorType Enum Test', () {
2323
{% for key, value in testData.enumData %}
2424
test('ErrorType.{{ key }} should have correct value', () {
25-
expect(ErrorType.{{ key }}.toString(), equals('ErrorType.{{ value }}'));
25+
expect(ErrorType.{{ error.type|title|replace({'_': ''}) }}.toString(), equals('ErrorType.{{ error.type }}'));
2626
});
2727
{% endfor %}
2828
});

templates/deno/src/exception.ts.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ export class {{ spec.title | caseUcfirst}}Exception {
1717
}
1818

1919
export enum ErrorType {
20-
{% for error in spec.definitions.appwriteException.error_types %}
20+
{% for error in spec.definitions.appwriteException.errorTypes %}
2121
/**
22-
* {{ error.description }}
22+
* {{ error.message }}
2323
*/
2424
{{ error.type|title|replace({'_': ''}) }} = "{{ error.type }}",
2525
{% endfor %}

templates/deno/tests/test_exception.ts.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {assertEquals} from "https://deno.land/std/testing/asserts.ts";
33
import {ErrorType} from "../src/exception.ts";
44

55
Deno.test("ErrorType values should match expected strings", () => {
6-
{% for key, value in testData.enumData %}
7-
assertEquals(ErrorType.{{ key }}, '{{ value }}');
6+
{% for error in spec.definitions.appwriteException.errorTypes %}
7+
assertEquals(ErrorType.{{ error.type|title|replace({'_': ''}) }}, '{{ error.type }}');
88
{% endfor %}
99
})

templates/dotnet/src/Appwrite/Exception.cs.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ namespace {{spec.title | caseUcfirst}}
2525
}
2626

2727
public enum ErrorType {
28-
{% for error in spec.definitions.appwriteException.error_types %}
28+
{% for error in spec.definitions.appwriteException.errorTypes %}
2929
/// <summary>
30-
/// {{ error.description }}
30+
/// {{ error.message }}
3131
/// </summary>
3232
{{ error.type|title|replace({'_': ''}) }},
3333
{% endfor %}

templates/dotnet/tests/TestException.cs.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ public class TestException
77
[TestMethod]
88
public void TestEnumValues()
99
{
10-
{% for key, value in testData.enumData %}
11-
Assert.AreEqual(ErrorType.{{ key }}, "{{ value }}");
10+
{% for error in spec.definitions.appwriteException.errorTypes %}
11+
Assert.AreEqual(ErrorType.{{ error.type|title|replace({'_': ''}) }}, "{{ error.type }}");
1212
{% endfor %}
1313
}
1414
}

0 commit comments

Comments
 (0)