Skip to content
This repository has been archived by the owner on Dec 23, 2024. It is now read-only.

Commit

Permalink
feature/tests: fixes after review
Browse files Browse the repository at this point in the history
  • Loading branch information
Maksim Konovalov committed Aug 30, 2024
1 parent cd7dd26 commit c8762cf
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 24 deletions.
3 changes: 0 additions & 3 deletions discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,6 @@ func (r *Router) DiscoveryAllBuckets(ctx context.Context) error {
errGr, ctx := errgroup.WithContext(ctx)

idToReplicasetRef := r.getIDToReplicaset()
if idToReplicasetRef == nil {
return fmt.Errorf("smth went wrong; replicasets map is empty")
}

for _, rs := range idToReplicasetRef {
rs := rs
Expand Down
14 changes: 0 additions & 14 deletions discovery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,6 @@ func TestSearchLock_WaitOnSearch(t *testing.T) {
require.True(t, time.Since(lockStart) < 12*time.Millisecond && time.Since(lockStart) > 9*time.Millisecond)
}

func TestRouter_DiscoveryAllBuckets(t *testing.T) {
ctx := context.TODO()

r := Router{
cfg: Config{
TotalBucketCount: uint64(256000),
Logger: &EmptyLogger{},
},
}

err := r.DiscoveryAllBuckets(ctx)
require.Error(t, err) // replicaset map is empty
}

func TestRouter_BucketResolve_InvalidBucketID(t *testing.T) {
ctx := context.TODO()

Expand Down
11 changes: 4 additions & 7 deletions vshard_shadow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,18 @@ import (
"github.com/KaymeKaydex/go-vshard-router/providers/static"
)

// Check that ErrorTopologyProvider implements TopologyProvider interface
var _ vshardrouter.TopologyProvider = (*ErrorTopologyProvider)(nil)
type errorTopologyProvider struct{}

type ErrorTopologyProvider struct{}

func (e *ErrorTopologyProvider) Init(_ vshardrouter.TopologyController) error {
func (e *errorTopologyProvider) Init(_ vshardrouter.TopologyController) error {
return fmt.Errorf("test error")
}
func (e *ErrorTopologyProvider) Close() {}
func (e *errorTopologyProvider) Close() {}

func TestNewRouter_ProviderError(t *testing.T) {
ctx := context.TODO()
_, err := vshardrouter.NewRouter(ctx, vshardrouter.Config{
TotalBucketCount: 256000,
TopologyProvider: &ErrorTopologyProvider{},
TopologyProvider: &errorTopologyProvider{},
})

require.ErrorIs(t, err, vshardrouter.ErrTopologyProvider)
Expand Down

0 comments on commit c8762cf

Please sign in to comment.