mirror of
https://github.com/psviderski/uncloud.git
synced 2026-10-06 13:18:58 +00:00
fix(caddyconfig): custom global Caddy config is preserved on regeneration,warn about last load error in 'uc caddy config' (fixes #412)
This commit is contained in:
1 parent
45d33d87dd
commit
ace8cbf974
18 files changed
+1210
-847
No files matched your search
@@ -0,0 +1,42 @@
|
||||
package caddyconfig
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestService_LastReconciliationError(t *testing.T) {
|
||||
service := NewService(t.TempDir())
|
||||
assert.NoError(t, service.LastReconciliationError())
|
||||
|
||||
service.setReconciliationResult(errors.New("global Caddy config rejected"))
|
||||
assert.EqualError(t, service.LastReconciliationError(), "global Caddy config rejected")
|
||||
|
||||
service.setReconciliationResult(nil)
|
||||
assert.NoError(t, service.LastReconciliationError())
|
||||
}
|
||||
|
||||
func TestService_LastReconciliationErrorConcurrent(t *testing.T) {
|
||||
service := NewService(t.TempDir())
|
||||
var wg sync.WaitGroup
|
||||
for range 10 {
|
||||
wg.Add(2)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
for range 100 {
|
||||
service.setReconciliationResult(errors.New("retry"))
|
||||
service.setReconciliationResult(nil)
|
||||
}
|
||||
}()
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
for range 100 {
|
||||
_ = service.LastReconciliationError()
|
||||
}
|
||||
}()
|
||||
}
|
||||
wg.Wait()
|
||||
}
|
||||
Reference in new issue
Block a user