Skip to content

Commit 063649f

Browse files
committed
Throw when container is resumed but not paused
1 parent 41611f5 commit 063649f

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/Testcontainers/Containers/DockerContainer.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -606,11 +606,6 @@ protected virtual async Task UnsafeUnpauseAsync(CancellationToken ct = default)
606606
return;
607607
}
608608

609-
if (!TestcontainersStates.Paused.Equals(State))
610-
{
611-
return;
612-
}
613-
614609
Unpausing?.Invoke(this, EventArgs.Empty);
615610

616611
await _client.UnpauseAsync(_container.ID, ct)

tests/Testcontainers.Platform.Linux.Tests/PauseUnpauseTest.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
using Docker.DotNet;
2+
using Xunit.Sdk;
3+
14
namespace Testcontainers.Tests;
25

36
public sealed class PauseUnpauseTest : IAsyncLifetime
@@ -28,4 +31,13 @@ await _container.UnpauseAsync()
2831
.ConfigureAwait(true);
2932
Assert.Equal(TestcontainersStates.Running, _container.State);
3033
}
34+
35+
[Fact]
36+
public async Task Unpauses_NotPaused_ContainerSuccessfully()
37+
{
38+
var thrown = await Assert.ThrowsAsync<DockerApiException>(async () => await _container.UnpauseAsync().ConfigureAwait(true));
39+
40+
Assert.Equal(HttpStatusCode.InternalServerError, thrown.StatusCode);
41+
Assert.Equal($"Docker API responded with status code=InternalServerError, response={{\"message\":\"Container {_container.Id} is not paused\"}}\n", thrown.Message);
42+
}
3143
}

0 commit comments

Comments
 (0)