Skip to content

Commit 37177dc

Browse files
committed
Update managed upload state fixture
1 parent 1dcfc3c commit 37177dc

1 file changed

Lines changed: 22 additions & 4 deletions

File tree

src/test/java/io/tus/java/client/TestGeneratedTusManagedUploadRuntime.java

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public class TestGeneratedTusManagedUploadRuntime extends MockServerProvider {
4848
false
4949
),
5050
new GeneratedTusManagedUploadTransport(
51+
"pending",
5152
"Location"
5253
),
5354
new GeneratedTusManagedUploadOutcomeExpectations(
@@ -98,6 +99,7 @@ public class TestGeneratedTusManagedUploadRuntime extends MockServerProvider {
9899
new GeneratedTusManagedUploadAttempt[] {
99100
new GeneratedTusManagedUploadAttempt(
100101
0,
102+
"running",
101103
"failed",
102104
new GeneratedTusManagedUploadFailure(
103105
true,
@@ -167,6 +169,7 @@ public class TestGeneratedTusManagedUploadRuntime extends MockServerProvider {
167169
),
168170
new GeneratedTusManagedUploadAttempt(
169171
1,
172+
"running",
170173
"succeeded",
171174
null,
172175
new GeneratedTusManagedUploadRequest[] {
@@ -236,6 +239,7 @@ public class TestGeneratedTusManagedUploadRuntime extends MockServerProvider {
236239
false
237240
),
238241
new GeneratedTusManagedUploadTransport(
242+
"pending",
239243
"Location"
240244
),
241245
new GeneratedTusManagedUploadOutcomeExpectations(
@@ -282,6 +286,7 @@ public class TestGeneratedTusManagedUploadRuntime extends MockServerProvider {
282286
new GeneratedTusManagedUploadAttempt[] {
283287
new GeneratedTusManagedUploadAttempt(
284288
0,
289+
"running",
285290
"failed",
286291
new GeneratedTusManagedUploadFailure(
287292
false,
@@ -329,6 +334,7 @@ public class TestGeneratedTusManagedUploadRuntime extends MockServerProvider {
329334
false
330335
),
331336
new GeneratedTusManagedUploadTransport(
337+
"pending",
332338
"Location"
333339
),
334340
new GeneratedTusManagedUploadOutcomeExpectations(
@@ -382,6 +388,7 @@ public class TestGeneratedTusManagedUploadRuntime extends MockServerProvider {
382388
new GeneratedTusManagedUploadAttempt[] {
383389
new GeneratedTusManagedUploadAttempt(
384390
0,
391+
"running",
385392
"failed",
386393
new GeneratedTusManagedUploadFailure(
387394
false,
@@ -418,6 +425,7 @@ public class TestGeneratedTusManagedUploadRuntime extends MockServerProvider {
418425
),
419426
new GeneratedTusManagedUploadAttempt(
420427
1,
428+
"running",
421429
"failed",
422430
new GeneratedTusManagedUploadFailure(
423431
false,
@@ -454,6 +462,7 @@ public class TestGeneratedTusManagedUploadRuntime extends MockServerProvider {
454462
),
455463
new GeneratedTusManagedUploadAttempt(
456464
2,
465+
"running",
457466
"failed",
458467
new GeneratedTusManagedUploadFailure(
459468
false,
@@ -501,6 +510,7 @@ public class TestGeneratedTusManagedUploadRuntime extends MockServerProvider {
501510
false
502511
),
503512
new GeneratedTusManagedUploadTransport(
513+
"pending",
504514
"Location"
505515
),
506516
new GeneratedTusManagedUploadOutcomeExpectations(
@@ -547,6 +557,7 @@ public class TestGeneratedTusManagedUploadRuntime extends MockServerProvider {
547557
new GeneratedTusManagedUploadAttempt[] {
548558
new GeneratedTusManagedUploadAttempt(
549559
0,
560+
"running",
550561
"failed",
551562
new GeneratedTusManagedUploadFailure(
552563
false,
@@ -585,7 +596,7 @@ public void testManagedUploadDurableRetryRuntime() throws Exception {
585596
File source = writeSourceFile(testCase);
586597
File ownedSource = ownedSourceFile(testCase, source);
587598
File stateFile = stateFile(testCase, source);
588-
recordState(testCase, states, stateFile, "pending");
599+
recordState(testCase, states, stateFile, testCase.initialState);
589600

590601
final GeneratedTusManagedUploadUrlStore urlStore = new GeneratedTusManagedUploadUrlStore();
591602
final TusClient client = new TusClient();
@@ -700,7 +711,7 @@ private TusExecutor managedExecutorFor(
700711
protected void makeAttempt() throws ProtocolException, IOException {
701712
GeneratedTusManagedUploadAttempt attempt = testCase.attempts[attemptIndex];
702713
attemptIndex += 1;
703-
recordState(testCase, states, stateFile, "running");
714+
recordState(testCase, states, stateFile, attempt.stateBeforeAttempt);
704715

705716
try {
706717
TusUpload upload = uploadFor(testCase, ownedSource);
@@ -795,7 +806,7 @@ private void prepareSourceBeforeProtocol(
795806
if (source.exists() && !source.delete()) {
796807
throw new IOException("Could not remove generated input source " + source);
797808
}
798-
recordState(testCase, states, stateFile, "running");
809+
recordState(testCase, states, stateFile, attempt.stateBeforeAttempt);
799810
try {
800811
copyDurableSource(testCase, source, ownedSource);
801812
} catch (IOException error) {
@@ -1015,6 +1026,7 @@ private static final class GeneratedTusManagedUploadRuntimeCase {
10151026
final boolean useDurableOsScheduler;
10161027
final boolean useFilesystemStateBackend;
10171028
final boolean usePlatformKeyValueStateBackend;
1029+
final String initialState;
10181030
final String locationHeaderName;
10191031
final boolean expectDeferredNetworkResult;
10201032
final boolean expectTerminalFailure;
@@ -1053,6 +1065,7 @@ private static final class GeneratedTusManagedUploadRuntimeCase {
10531065
this.useFilesystemStateBackend = runtimeCapabilities.useFilesystemStateBackend;
10541066
this.usePlatformKeyValueStateBackend =
10551067
runtimeCapabilities.usePlatformKeyValueStateBackend;
1068+
this.initialState = transport.initialState;
10561069
this.locationHeaderName = transport.locationHeaderName;
10571070
this.expectDeferredNetworkResult = outcomeExpectations.expectDeferredNetworkResult;
10581071
this.expectTerminalFailure = outcomeExpectations.expectTerminalFailure;
@@ -1122,9 +1135,11 @@ private static final class GeneratedTusManagedUploadRuntimeCapabilities {
11221135
}
11231136

11241137
private static final class GeneratedTusManagedUploadTransport {
1138+
final String initialState;
11251139
final String locationHeaderName;
11261140

1127-
GeneratedTusManagedUploadTransport(String locationHeaderName) {
1141+
GeneratedTusManagedUploadTransport(String initialState, String locationHeaderName) {
1142+
this.initialState = initialState;
11281143
this.locationHeaderName = locationHeaderName;
11291144
}
11301145
}
@@ -1208,16 +1223,19 @@ private static final class GeneratedTusManagedUploadInput {
12081223
private static final class GeneratedTusManagedUploadAttempt {
12091224
final int attemptIndex;
12101225
final String stateAfterAttempt;
1226+
final String stateBeforeAttempt;
12111227
final GeneratedTusManagedUploadFailure failure;
12121228
final GeneratedTusManagedUploadRequest[] requests;
12131229

12141230
GeneratedTusManagedUploadAttempt(
12151231
int attemptIndex,
1232+
String stateBeforeAttempt,
12161233
String stateAfterAttempt,
12171234
GeneratedTusManagedUploadFailure failure,
12181235
GeneratedTusManagedUploadRequest[] requests) {
12191236
this.attemptIndex = attemptIndex;
12201237
this.stateAfterAttempt = stateAfterAttempt;
1238+
this.stateBeforeAttempt = stateBeforeAttempt;
12211239
this.failure = failure;
12221240
this.requests = requests;
12231241
}

0 commit comments

Comments
 (0)