2019-06-18 16:47:29 +00:00
|
|
|
package updater
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/facebookgo/grace/gracenet"
|
2020-11-25 06:55:13 +00:00
|
|
|
"github.com/rs/zerolog"
|
2019-06-18 16:47:29 +00:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestDisabledAutoUpdater(t *testing.T) {
|
|
|
|
listeners := &gracenet.Net{}
|
2020-11-25 06:55:13 +00:00
|
|
|
log := zerolog.Nop()
|
|
|
|
autoupdater := NewAutoUpdater(0, listeners, &log)
|
2019-06-18 16:47:29 +00:00
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
errC := make(chan error)
|
|
|
|
go func() {
|
|
|
|
errC <- autoupdater.Run(ctx)
|
|
|
|
}()
|
|
|
|
|
|
|
|
assert.False(t, autoupdater.configurable.enabled)
|
|
|
|
assert.Equal(t, DefaultCheckUpdateFreq, autoupdater.configurable.freq)
|
|
|
|
|
|
|
|
cancel()
|
|
|
|
// Make sure that autoupdater terminates after canceling the context
|
|
|
|
assert.Equal(t, context.Canceled, <-errC)
|
|
|
|
}
|