github.com/thanos-io/thanos@v0.32.5/pkg/store/recover_test.go (about)

     1  // Copyright (c) The Thanos Authors.
     2  // Licensed under the Apache License 2.0.
     3  
     4  package store
     5  
     6  import (
     7  	"context"
     8  	"testing"
     9  
    10  	"github.com/efficientgo/core/testutil"
    11  	"github.com/go-kit/log"
    12  
    13  	"github.com/thanos-io/thanos/pkg/store/storepb"
    14  )
    15  
    16  func TestRecoverableServer(t *testing.T) {
    17  	logger := log.NewNopLogger()
    18  	store := NewRecoverableStoreServer(logger, &panicStoreServer{})
    19  
    20  	ctx, cancel := context.WithCancel(context.Background())
    21  	defer cancel()
    22  	srv := storepb.NewInProcessStream(ctx, 1)
    23  
    24  	testutil.Ok(t, store.Series(&storepb.SeriesRequest{}, srv))
    25  }
    26  
    27  type panicStoreServer struct {
    28  	storepb.StoreServer
    29  }
    30  
    31  func (m *panicStoreServer) Series(_ *storepb.SeriesRequest, _ storepb.Store_SeriesServer) error {
    32  	panic("something went wrong.")
    33  }