github.com/keybase/client/go@v0.0.0-20240309051027-028f7c731f8b/kbfs/libkbfs/mdserver_local_config_test.go (about)

     1  // Copyright 2016 Keybase Inc. All rights reserved.
     2  // Use of this source code is governed by a BSD
     3  // license that can be found in the LICENSE file.
     4  
     5  package libkbfs
     6  
     7  import (
     8  	"testing"
     9  
    10  	"github.com/keybase/client/go/kbfs/idutil"
    11  	"github.com/keybase/client/go/kbfs/kbfsmd"
    12  	"github.com/keybase/client/go/kbfs/test/clocktest"
    13  	"golang.org/x/net/context"
    14  )
    15  
    16  type singleCurrentSessionGetter struct {
    17  	session idutil.SessionInfo
    18  }
    19  
    20  func (csg singleCurrentSessionGetter) GetCurrentSession(ctx context.Context) (
    21  	idutil.SessionInfo, error) {
    22  	return csg.session, nil
    23  }
    24  
    25  type testMDServerLocalConfig struct {
    26  	codecGetter
    27  	logMaker
    28  	clock  Clock
    29  	crypto cryptoPure
    30  	csg    idutil.CurrentSessionGetter
    31  }
    32  
    33  func newTestMDServerLocalConfig(
    34  	t *testing.T, csg idutil.CurrentSessionGetter) testMDServerLocalConfig {
    35  	cg := newTestCodecGetter()
    36  	return testMDServerLocalConfig{
    37  		codecGetter: cg,
    38  		logMaker:    newTestLogMaker(t),
    39  		clock:       clocktest.NewTestClockNow(),
    40  		crypto:      MakeCryptoCommon(cg.Codec(), makeBlockCryptV1()),
    41  		csg:         csg,
    42  	}
    43  }
    44  
    45  func (c testMDServerLocalConfig) Clock() Clock {
    46  	return c.clock
    47  }
    48  
    49  func (c testMDServerLocalConfig) cryptoPure() cryptoPure {
    50  	return c.crypto
    51  }
    52  
    53  func (c testMDServerLocalConfig) currentSessionGetter() idutil.CurrentSessionGetter {
    54  	return c.csg
    55  }
    56  
    57  func (c testMDServerLocalConfig) MetadataVersion() kbfsmd.MetadataVer {
    58  	return defaultClientMetadataVer
    59  }
    60  
    61  func (c testMDServerLocalConfig) teamMembershipChecker() kbfsmd.TeamMembershipChecker {
    62  	// TODO: support team TLFs in the test mdserver.
    63  	return nil
    64  }