Skip to content

Commit

Permalink
add another test
Browse files Browse the repository at this point in the history
Signed-off-by: Tim Vaillancourt <[email protected]>
  • Loading branch information
timvaillancourt committed Feb 10, 2025
1 parent ce428ee commit 7d48dc2
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions go/vt/vtorc/logic/cell_discovery_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
Copyright 2025 The Vitess Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package logic

import (
"context"
"testing"

"github.com/stretchr/testify/require"

"vitess.io/vitess/go/vt/topo/memorytopo"
"vitess.io/vitess/go/vt/vtorc/db"
"vitess.io/vitess/go/vt/vtorc/inst"
)

func TestRefreshAllCells(t *testing.T) {
// Store the old flags and restore on test completion
oldTs := ts
oldClustersToWatch := clustersToWatch
defer func() {
ts = oldTs
clustersToWatch = oldClustersToWatch
}()

db.ClearVTOrcDatabase()
defer func() {
db.ClearVTOrcDatabase()
}()

ctx, cancel := context.WithCancel(context.Background())
defer cancel()
ts = memorytopo.NewServer(ctx, "zone1", "zone2", "zone3")

require.NoError(t, RefreshCells(ctx))

cells, err := inst.ReadCells()
require.NoError(t, err)
require.Equal(t, []string{"zone1", "zone2", "zone3"}, cells)
}

0 comments on commit 7d48dc2

Please sign in to comment.