CI / CI (pull_request) Successful in 4m32s
- internal/temporal/client.go: robust client with retry + TLS + health check - internal/temporal/worker.go: worker creation, registration, lifecycle - internal/temporal/context.go: timeout helpers - k8s/worker-deployment.yaml: 2-10 replica HPA, health probes, security context - k8s/workflow-runner-deployment.yaml: singleton runner with probes - k8s/kustomization.yaml: updated resource list, removed missing ref Tests: 11 pass (client_test.go + worker_test.go) Build: go build ./... clean Kustomize: dry-run validated
56 lines
1.4 KiB
Go
56 lines
1.4 KiB
Go
package temporal
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestWorkerConfigDefaults(t *testing.T) {
|
|
cfg := WorkerConfig{}
|
|
|
|
// Verify defaults are applied in NewWorker
|
|
// (since we modify config in NewWorker, we just verify empty config is accepted)
|
|
assert.Equal(t, "", cfg.TaskQueue)
|
|
assert.Equal(t, 0, cfg.MaxConcurrentActivity)
|
|
assert.Equal(t, 0, cfg.MaxConcurrentWorkflow)
|
|
assert.Equal(t, "", cfg.Identity)
|
|
}
|
|
|
|
func TestRegisterWorkflowWithNilWorker(t *testing.T) {
|
|
err := RegisterWorkflow(nil, func() {})
|
|
assert.Error(t, err)
|
|
assert.Equal(t, "worker is nil", err.Error())
|
|
}
|
|
|
|
func TestRegisterActivityWithNilWorker(t *testing.T) {
|
|
err := RegisterActivity(nil, func() {})
|
|
assert.Error(t, err)
|
|
assert.Equal(t, "worker is nil", err.Error())
|
|
}
|
|
|
|
func TestRunWorkerWithNilWorker(t *testing.T) {
|
|
err := RunWorker(nil)
|
|
assert.Error(t, err)
|
|
assert.Equal(t, "worker is nil", err.Error())
|
|
}
|
|
|
|
func TestStopWorkerWithNilWorker(t *testing.T) {
|
|
// Should not panic
|
|
StopWorker(nil)
|
|
}
|
|
|
|
func TestWorkerConfigCustomValues(t *testing.T) {
|
|
cfg := WorkerConfig{
|
|
TaskQueue: "custom-queue",
|
|
MaxConcurrentActivity: 20,
|
|
MaxConcurrentWorkflow: 30,
|
|
Identity: "custom-identity",
|
|
}
|
|
|
|
assert.Equal(t, "custom-queue", cfg.TaskQueue)
|
|
assert.Equal(t, 20, cfg.MaxConcurrentActivity)
|
|
assert.Equal(t, 30, cfg.MaxConcurrentWorkflow)
|
|
assert.Equal(t, "custom-identity", cfg.Identity)
|
|
}
|