зеркало из https://github.com/github/vitess-gh.git
Resetting the getVersionFromTablet variable for unit test.
This commit is contained in:
Родитель
dcab010154
Коммит
b0e00a3341
|
@ -43,6 +43,10 @@ func expvarHandler(gitRev *string) func(http.ResponseWriter, *http.Request) {
|
|||
}
|
||||
|
||||
func TestVersion(t *testing.T) {
|
||||
// We need to run this test with the /debug/vars version of the
|
||||
// plugin.
|
||||
wrangler.ResetDebugVarsGetVersion()
|
||||
|
||||
// Initialize our environment
|
||||
ts := zktopo.NewTestServer(t, []string{"cell1", "cell2"})
|
||||
wr := wrangler.New(logutil.NewConsoleLogger(), ts, tmclient.NewTabletManagerClient(), time.Second)
|
||||
|
|
|
@ -18,7 +18,7 @@ import (
|
|||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
var getVersionFromTablet = func(tabletAddr string) (string, error) {
|
||||
var getVersionFromTabletDebugVars = func(tabletAddr string) (string, error) {
|
||||
resp, err := http.Get("http://" + tabletAddr + "/debug/vars")
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
@ -44,6 +44,16 @@ var getVersionFromTablet = func(tabletAddr string) (string, error) {
|
|||
return version, nil
|
||||
}
|
||||
|
||||
var getVersionFromTablet = getVersionFromTabletDebugVars
|
||||
|
||||
// ResetDebugVarsGetVersion is used by tests to reset the
|
||||
// getVersionFromTablet variable to the default one. That way we can
|
||||
// run the unit tests in testlib/ even when another implementation of
|
||||
// getVersionFromTablet is used.
|
||||
func ResetDebugVarsGetVersion() {
|
||||
getVersionFromTablet = getVersionFromTabletDebugVars
|
||||
}
|
||||
|
||||
// GetVersion returns the version string from a tablet
|
||||
func (wr *Wrangler) GetVersion(ctx context.Context, tabletAlias topo.TabletAlias) (string, error) {
|
||||
tablet, err := wr.ts.GetTablet(ctx, tabletAlias)
|
||||
|
|
Загрузка…
Ссылка в новой задаче