Skip to content

Commit 165f147

Browse files
author
serverpod_cloud
committed
feat: 605244700c5d9d3b74809a92d5ba00ccf9115219
1 parent 84612d8 commit 165f147

3 files changed

Lines changed: 149 additions & 0 deletions

File tree

ground_control_client/lib/src/test_tools/builders/builders.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ export 'billing/billing_info_builder.dart';
33
export 'billing/payment_method_builder.dart';
44
export 'billing/payment_method_card_builder.dart';
55
export 'billing/payment_setup_intent_builder.dart';
6+
export 'capsule_builder.dart';
7+
export 'deploy_attempt_builder.dart';
68
export 'role_builder.dart';
79
export 'project_builder.dart';
810
export 'plan_info_builder.dart';
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
import 'package:ground_control_client/ground_control_client.dart';
2+
3+
class CapsuleBuilder {
4+
int? _id;
5+
String _name;
6+
String _cloudCapsuleId;
7+
ServerpodRegion _region;
8+
int _projectId;
9+
Project? _project;
10+
List<EnvironmentVariable>? _environmentVariables;
11+
List<CustomDomainName>? _domainNames;
12+
CapsuleResource? _resourceConfig;
13+
14+
CapsuleBuilder()
15+
: _id = null,
16+
_name = 'test-capsule',
17+
_cloudCapsuleId = 'test-capsule-id',
18+
_region = ServerpodRegion.europe,
19+
_projectId = 1,
20+
_project = null,
21+
_environmentVariables = [],
22+
_domainNames = [],
23+
_resourceConfig = null;
24+
25+
CapsuleBuilder withId(final int? id) {
26+
_id = id;
27+
return this;
28+
}
29+
30+
CapsuleBuilder withName(final String name) {
31+
_name = name;
32+
return this;
33+
}
34+
35+
CapsuleBuilder withCloudCapsuleId(final String cloudCapsuleId) {
36+
_cloudCapsuleId = cloudCapsuleId;
37+
return this;
38+
}
39+
40+
CapsuleBuilder withRegion(final ServerpodRegion region) {
41+
_region = region;
42+
return this;
43+
}
44+
45+
CapsuleBuilder withProjectId(final int projectId) {
46+
_projectId = projectId;
47+
return this;
48+
}
49+
50+
CapsuleBuilder withProject(final Project? project) {
51+
_project = project;
52+
if (project != null) {
53+
_projectId = project.id ?? 1;
54+
}
55+
return this;
56+
}
57+
58+
CapsuleBuilder withEnvironmentVariables(
59+
final List<EnvironmentVariable>? environmentVariables,
60+
) {
61+
_environmentVariables = environmentVariables;
62+
return this;
63+
}
64+
65+
CapsuleBuilder withDomainNames(final List<CustomDomainName>? domainNames) {
66+
_domainNames = domainNames;
67+
return this;
68+
}
69+
70+
CapsuleBuilder withResourceConfig(final CapsuleResource? resourceConfig) {
71+
_resourceConfig = resourceConfig;
72+
return this;
73+
}
74+
75+
Capsule build() {
76+
return Capsule(
77+
id: _id,
78+
name: _name,
79+
cloudCapsuleId: _cloudCapsuleId,
80+
region: _region,
81+
projectId: _projectId,
82+
project: _project,
83+
environmentVariables: _environmentVariables,
84+
domainNames: _domainNames,
85+
resourceConfig: _resourceConfig,
86+
);
87+
}
88+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import 'package:ground_control_client/ground_control_client.dart';
2+
3+
class DeployAttemptBuilder {
4+
String _cloudCapsuleId;
5+
String _attemptId;
6+
DeployProgressStatus _status;
7+
DateTime? _startedAt;
8+
DateTime? _endedAt;
9+
String? _statusInfo;
10+
11+
DeployAttemptBuilder()
12+
: _cloudCapsuleId = 'test-capsule-id',
13+
_attemptId = 'test-attempt-id',
14+
_status = DeployProgressStatus.awaiting,
15+
_startedAt = DateTime.now(),
16+
_endedAt = null,
17+
_statusInfo = null;
18+
19+
DeployAttemptBuilder withCloudCapsuleId(final String cloudCapsuleId) {
20+
_cloudCapsuleId = cloudCapsuleId;
21+
return this;
22+
}
23+
24+
DeployAttemptBuilder withAttemptId(final String attemptId) {
25+
_attemptId = attemptId;
26+
return this;
27+
}
28+
29+
DeployAttemptBuilder withStatus(final DeployProgressStatus status) {
30+
_status = status;
31+
return this;
32+
}
33+
34+
DeployAttemptBuilder withStartedAt(final DateTime? startedAt) {
35+
_startedAt = startedAt;
36+
return this;
37+
}
38+
39+
DeployAttemptBuilder withEndedAt(final DateTime? endedAt) {
40+
_endedAt = endedAt;
41+
return this;
42+
}
43+
44+
DeployAttemptBuilder withStatusInfo(final String? statusInfo) {
45+
_statusInfo = statusInfo;
46+
return this;
47+
}
48+
49+
DeployAttempt build() {
50+
return DeployAttempt(
51+
cloudCapsuleId: _cloudCapsuleId,
52+
attemptId: _attemptId,
53+
status: _status,
54+
startedAt: _startedAt,
55+
endedAt: _endedAt,
56+
statusInfo: _statusInfo,
57+
);
58+
}
59+
}

0 commit comments

Comments
 (0)