cloudflare/cloudflared
Publicmirrored from https://github.com/cloudflare/cloudflaredAvailable
cmd/cloudflared/updater/update_test.go
26lines · modecode
| 1 | package updater |
| 2 | |
| 3 | import ( |
| 4 | "context" |
| 5 | "testing" |
| 6 | |
| 7 | "github.com/facebookgo/grace/gracenet" |
| 8 | "github.com/stretchr/testify/assert" |
| 9 | ) |
| 10 | |
| 11 | func TestDisabledAutoUpdater(t *testing.T) { |
| 12 | listeners := &gracenet.Net{} |
| 13 | autoupdater := NewAutoUpdater(0, listeners) |
| 14 | ctx, cancel := context.WithCancel(context.Background()) |
| 15 | errC := make(chan error) |
| 16 | go func() { |
| 17 | errC <- autoupdater.Run(ctx) |
| 18 | }() |
| 19 | |
| 20 | assert.False(t, autoupdater.configurable.enabled) |
| 21 | assert.Equal(t, DefaultCheckUpdateFreq, autoupdater.configurable.freq) |
| 22 | |
| 23 | cancel() |
| 24 | // Make sure that autoupdater terminates after canceling the context |
| 25 | assert.Equal(t, context.Canceled, <-errC) |
| 26 | } |
| 27 | |