test: use minimal ReadinessDelay to speed up tests
Setting ReadinessDelay to 0 defaults to 5s. Use time.Millisecond instead to bypass the default and run tests instantly.
- commit
- 6c2bf1e88f9ac726c673276b514f4c71bce76753
- author
- brice · · 2026-01-17 11:42 UTC
- parent
- 94edfa9
- signature
- unsigned
1 file · +10 -9
M internal/usecase/container/service_test.go +10 -9
| @@ -4,6 +4,7 @@ import ( | |||
| 4 | 4 | "context" | |
| 5 | 5 | "errors" | |
| 6 | 6 | "testing" | |
| 7 | + | "time" | |
| 7 | 8 | ||
| 8 | 9 | "github.com/bnema/zerowrap" | |
| 9 | 10 | "github.com/stretchr/testify/assert" | |
| @@ -25,7 +26,7 @@ func TestService_Deploy_Success(t *testing.T) { | |||
| 25 | 26 | config := Config{ | |
| 26 | 27 | NetworkIsolation: false, | |
| 27 | 28 | VolumeAutoCreate: false, | |
| 28 | - | ReadinessDelay: 0, // No delay for tests | |
| 29 | + | ReadinessDelay: time.Millisecond, // Minimal delay for tests | |
| 29 | 30 | } | |
| 30 | 31 | ||
| 31 | 32 | svc := NewService(runtime, envLoader, eventBus, nil, config) | |
| @@ -124,7 +125,7 @@ func TestService_Deploy_ReplacesExistingContainer(t *testing.T) { | |||
| 124 | 125 | eventBus := mocks.NewMockEventPublisher(t) | |
| 125 | 126 | ||
| 126 | 127 | config := Config{ | |
| 127 | - | ReadinessDelay: 0, // No delay for tests | |
| 128 | + | ReadinessDelay: time.Millisecond, // Minimal delay for tests | |
| 128 | 129 | } | |
| 129 | 130 | svc := NewService(runtime, envLoader, eventBus, nil, config) | |
| 130 | 131 | ctx := testContext() | |
| @@ -199,7 +200,7 @@ func TestService_Deploy_WithNetworkIsolation(t *testing.T) { | |||
| 199 | 200 | config := Config{ | |
| 200 | 201 | NetworkIsolation: true, | |
| 201 | 202 | NetworkPrefix: "gordon", | |
| 202 | - | ReadinessDelay: 0, // No delay for tests | |
| 203 | + | ReadinessDelay: time.Millisecond, // Minimal delay for tests | |
| 203 | 204 | } | |
| 204 | 205 | svc := NewService(runtime, envLoader, eventBus, nil, config) | |
| 205 | 206 | ctx := testContext() | |
| @@ -250,7 +251,7 @@ func TestService_Deploy_WithVolumeAutoCreate(t *testing.T) { | |||
| 250 | 251 | config := Config{ | |
| 251 | 252 | VolumeAutoCreate: true, | |
| 252 | 253 | VolumePrefix: "gordon", | |
| 253 | - | ReadinessDelay: 0, // No delay for tests | |
| 254 | + | ReadinessDelay: time.Millisecond, // Minimal delay for tests | |
| 254 | 255 | } | |
| 255 | 256 | svc := NewService(runtime, envLoader, eventBus, nil, config) | |
| 256 | 257 | ctx := testContext() | |
| @@ -723,7 +724,7 @@ func TestService_Deploy_InternalDeployForcesPull(t *testing.T) { | |||
| 723 | 724 | RegistryPort: 5000, | |
| 724 | 725 | InternalRegistryUsername: "internal", | |
| 725 | 726 | InternalRegistryPassword: "secret", | |
| 726 | - | ReadinessDelay: 0, | |
| 727 | + | ReadinessDelay: time.Millisecond, | |
| 727 | 728 | } | |
| 728 | 729 | ||
| 729 | 730 | svc := NewService(runtime, envLoader, eventBus, nil, config) | |
| @@ -791,7 +792,7 @@ func TestService_AutoStart_StartsNewContainers(t *testing.T) { | |||
| 791 | 792 | eventBus := mocks.NewMockEventPublisher(t) | |
| 792 | 793 | ||
| 793 | 794 | config := Config{ | |
| 794 | - | ReadinessDelay: 0, | |
| 795 | + | ReadinessDelay: time.Millisecond, | |
| 795 | 796 | } | |
| 796 | 797 | svc := NewService(runtime, envLoader, eventBus, nil, config) | |
| 797 | 798 | ctx := testContext() | |
| @@ -834,7 +835,7 @@ func TestService_AutoStart_SkipsExistingContainers(t *testing.T) { | |||
| 834 | 835 | eventBus := mocks.NewMockEventPublisher(t) | |
| 835 | 836 | ||
| 836 | 837 | config := Config{ | |
| 837 | - | ReadinessDelay: 0, | |
| 838 | + | ReadinessDelay: time.Millisecond, | |
| 838 | 839 | } | |
| 839 | 840 | svc := NewService(runtime, envLoader, eventBus, nil, config) | |
| 840 | 841 | ctx := testContext() | |
| @@ -906,7 +907,7 @@ func TestService_Deploy_OrphanCleanupSkipsTrackedContainer(t *testing.T) { | |||
| 906 | 907 | eventBus := mocks.NewMockEventPublisher(t) | |
| 907 | 908 | ||
| 908 | 909 | config := Config{ | |
| 909 | - | ReadinessDelay: 0, // No delay for tests | |
| 910 | + | ReadinessDelay: time.Millisecond, // Minimal delay for tests | |
| 910 | 911 | } | |
| 911 | 912 | svc := NewService(runtime, envLoader, eventBus, nil, config) | |
| 912 | 913 | ctx := testContext() | |
| @@ -990,7 +991,7 @@ func TestService_Deploy_OrphanCleanupRemovesTrueOrphans(t *testing.T) { | |||
| 990 | 991 | eventBus := mocks.NewMockEventPublisher(t) | |
| 991 | 992 | ||
| 992 | 993 | config := Config{ | |
| 993 | - | ReadinessDelay: 0, // No delay for tests | |
| 994 | + | ReadinessDelay: time.Millisecond, // Minimal delay for tests | |
| 994 | 995 | } | |
| 995 | 996 | svc := NewService(runtime, envLoader, eventBus, nil, config) | |
| 996 | 997 | ctx := testContext() | |
| @@ -4,6 +4,7 @@ import ( | |||||
| 4 | "context" | 4 | "context" | ||
| 5 | "errors" | 5 | "errors" | ||
| 6 | "testing" | 6 | "testing" | ||
| 7 | + | "time" | |||
| 7 | 8 | ||||
| 8 | "github.com/bnema/zerowrap" | 9 | "github.com/bnema/zerowrap" | ||
| 9 | "github.com/stretchr/testify/assert" | 10 | "github.com/stretchr/testify/assert" | ||
| @@ -25,7 +26,7 @@ func TestService_Deploy_Success(t *testing.T) { | |||||
| 25 | config := Config{ | 26 | config := Config{ | ||
| 26 | NetworkIsolation: false, | 27 | NetworkIsolation: false, | ||
| 27 | VolumeAutoCreate: false, | 28 | VolumeAutoCreate: false, | ||
| 28 | - | ReadinessDelay: 0, // No delay for tests | 29 | + | ReadinessDelay: time.Millisecond, // Minimal delay for tests |
| 29 | } | 30 | } | ||
| 30 | 31 | ||||
| 31 | svc := NewService(runtime, envLoader, eventBus, nil, config) | 32 | svc := NewService(runtime, envLoader, eventBus, nil, config) | ||
| @@ -124,7 +125,7 @@ func TestService_Deploy_ReplacesExistingContainer(t *testing.T) { | |||||
| 124 | eventBus := mocks.NewMockEventPublisher(t) | 125 | eventBus := mocks.NewMockEventPublisher(t) | ||
| 125 | 126 | ||||
| 126 | config := Config{ | 127 | config := Config{ | ||
| 127 | - | ReadinessDelay: 0, // No delay for tests | 128 | + | ReadinessDelay: time.Millisecond, // Minimal delay for tests |
| 128 | } | 129 | } | ||
| 129 | svc := NewService(runtime, envLoader, eventBus, nil, config) | 130 | svc := NewService(runtime, envLoader, eventBus, nil, config) | ||
| 130 | ctx := testContext() | 131 | ctx := testContext() | ||
| @@ -199,7 +200,7 @@ func TestService_Deploy_WithNetworkIsolation(t *testing.T) { | |||||
| 199 | config := Config{ | 200 | config := Config{ | ||
| 200 | NetworkIsolation: true, | 201 | NetworkIsolation: true, | ||
| 201 | NetworkPrefix: "gordon", | 202 | NetworkPrefix: "gordon", | ||
| 202 | - | ReadinessDelay: 0, // No delay for tests | 203 | + | ReadinessDelay: time.Millisecond, // Minimal delay for tests |
| 203 | } | 204 | } | ||
| 204 | svc := NewService(runtime, envLoader, eventBus, nil, config) | 205 | svc := NewService(runtime, envLoader, eventBus, nil, config) | ||
| 205 | ctx := testContext() | 206 | ctx := testContext() | ||
| @@ -250,7 +251,7 @@ func TestService_Deploy_WithVolumeAutoCreate(t *testing.T) { | |||||
| 250 | config := Config{ | 251 | config := Config{ | ||
| 251 | VolumeAutoCreate: true, | 252 | VolumeAutoCreate: true, | ||
| 252 | VolumePrefix: "gordon", | 253 | VolumePrefix: "gordon", | ||
| 253 | - | ReadinessDelay: 0, // No delay for tests | 254 | + | ReadinessDelay: time.Millisecond, // Minimal delay for tests |
| 254 | } | 255 | } | ||
| 255 | svc := NewService(runtime, envLoader, eventBus, nil, config) | 256 | svc := NewService(runtime, envLoader, eventBus, nil, config) | ||
| 256 | ctx := testContext() | 257 | ctx := testContext() | ||
| @@ -723,7 +724,7 @@ func TestService_Deploy_InternalDeployForcesPull(t *testing.T) { | |||||
| 723 | RegistryPort: 5000, | 724 | RegistryPort: 5000, | ||
| 724 | InternalRegistryUsername: "internal", | 725 | InternalRegistryUsername: "internal", | ||
| 725 | InternalRegistryPassword: "secret", | 726 | InternalRegistryPassword: "secret", | ||
| 726 | - | ReadinessDelay: 0, | 727 | + | ReadinessDelay: time.Millisecond, |
| 727 | } | 728 | } | ||
| 728 | 729 | ||||
| 729 | svc := NewService(runtime, envLoader, eventBus, nil, config) | 730 | svc := NewService(runtime, envLoader, eventBus, nil, config) | ||
| @@ -791,7 +792,7 @@ func TestService_AutoStart_StartsNewContainers(t *testing.T) { | |||||
| 791 | eventBus := mocks.NewMockEventPublisher(t) | 792 | eventBus := mocks.NewMockEventPublisher(t) | ||
| 792 | 793 | ||||
| 793 | config := Config{ | 794 | config := Config{ | ||
| 794 | - | ReadinessDelay: 0, | 795 | + | ReadinessDelay: time.Millisecond, |
| 795 | } | 796 | } | ||
| 796 | svc := NewService(runtime, envLoader, eventBus, nil, config) | 797 | svc := NewService(runtime, envLoader, eventBus, nil, config) | ||
| 797 | ctx := testContext() | 798 | ctx := testContext() | ||
| @@ -834,7 +835,7 @@ func TestService_AutoStart_SkipsExistingContainers(t *testing.T) { | |||||
| 834 | eventBus := mocks.NewMockEventPublisher(t) | 835 | eventBus := mocks.NewMockEventPublisher(t) | ||
| 835 | 836 | ||||
| 836 | config := Config{ | 837 | config := Config{ | ||
| 837 | - | ReadinessDelay: 0, | 838 | + | ReadinessDelay: time.Millisecond, |
| 838 | } | 839 | } | ||
| 839 | svc := NewService(runtime, envLoader, eventBus, nil, config) | 840 | svc := NewService(runtime, envLoader, eventBus, nil, config) | ||
| 840 | ctx := testContext() | 841 | ctx := testContext() | ||
| @@ -906,7 +907,7 @@ func TestService_Deploy_OrphanCleanupSkipsTrackedContainer(t *testing.T) { | |||||
| 906 | eventBus := mocks.NewMockEventPublisher(t) | 907 | eventBus := mocks.NewMockEventPublisher(t) | ||
| 907 | 908 | ||||
| 908 | config := Config{ | 909 | config := Config{ | ||
| 909 | - | ReadinessDelay: 0, // No delay for tests | 910 | + | ReadinessDelay: time.Millisecond, // Minimal delay for tests |
| 910 | } | 911 | } | ||
| 911 | svc := NewService(runtime, envLoader, eventBus, nil, config) | 912 | svc := NewService(runtime, envLoader, eventBus, nil, config) | ||
| 912 | ctx := testContext() | 913 | ctx := testContext() | ||
| @@ -990,7 +991,7 @@ func TestService_Deploy_OrphanCleanupRemovesTrueOrphans(t *testing.T) { | |||||
| 990 | eventBus := mocks.NewMockEventPublisher(t) | 991 | eventBus := mocks.NewMockEventPublisher(t) | ||
| 991 | 992 | ||||
| 992 | config := Config{ | 993 | config := Config{ | ||
| 993 | - | ReadinessDelay: 0, // No delay for tests | 994 | + | ReadinessDelay: time.Millisecond, // Minimal delay for tests |
| 994 | } | 995 | } | ||
| 995 | svc := NewService(runtime, envLoader, eventBus, nil, config) | 996 | svc := NewService(runtime, envLoader, eventBus, nil, config) | ||
| 996 | ctx := testContext() | 997 | ctx := testContext() | ||