mirror of
https://github.com/fumiama/terasu-cloudflared.git
synced 2026-06-10 05:04:15 +08:00
TUN-3989: Check in with Updater service in more situations and convey messages to user
This commit is contained in:
@@ -2,17 +2,19 @@ package updater
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"testing"
|
||||
|
||||
"github.com/facebookgo/grace/gracenet"
|
||||
"github.com/rs/zerolog"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
func TestDisabledAutoUpdater(t *testing.T) {
|
||||
listeners := &gracenet.Net{}
|
||||
log := zerolog.Nop()
|
||||
autoupdater := NewAutoUpdater(0, listeners, &log)
|
||||
autoupdater := NewAutoUpdater(false, 0, listeners, &log)
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
errC := make(chan error)
|
||||
go func() {
|
||||
@@ -26,3 +28,13 @@ func TestDisabledAutoUpdater(t *testing.T) {
|
||||
// Make sure that autoupdater terminates after canceling the context
|
||||
assert.Equal(t, context.Canceled, <-errC)
|
||||
}
|
||||
|
||||
func TestCheckInWithUpdater(t *testing.T) {
|
||||
flagSet := flag.NewFlagSet(t.Name(), flag.PanicOnError)
|
||||
cliCtx := cli.NewContext(cli.NewApp(), flagSet, nil)
|
||||
|
||||
warningChecker := StartWarningCheck(cliCtx)
|
||||
warning := warningChecker.getWarning()
|
||||
// Assuming this runs either on a release or development version, then the Worker will never have anything to tell us.
|
||||
assert.Empty(t, warning)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user