github.com/NVIDIA/aistore@v1.3.23-0.20240517131212-7df6609be51d/core/mock/xact_mock.go (about)

     1  // Package mock provides a variety of mock implementations used for testing.
     2  /*
     3   * Copyright (c) 2018-2022, NVIDIA CORPORATION. All rights reserved.
     4   */
     5  package mock
     6  
     7  import (
     8  	"sync"
     9  
    10  	"github.com/NVIDIA/aistore/cmn/cos"
    11  	"github.com/NVIDIA/aistore/core"
    12  	"github.com/NVIDIA/aistore/xact"
    13  )
    14  
    15  func init() {
    16  	cos.InitShortID(0)
    17  }
    18  
    19  // interface guard
    20  var _ core.Xact = (*XactMock)(nil)
    21  
    22  // XactMock provides core.Xact interface with mocked return values.
    23  type XactMock struct {
    24  	xact.Base
    25  }
    26  
    27  func (*XactMock) Run(*sync.WaitGroup) {
    28  	panic("unused")
    29  }
    30  
    31  func NewXact(kind string) *XactMock {
    32  	xctn := &XactMock{}
    33  	xctn.InitBase(cos.GenUUID(), kind, nil)
    34  	return xctn
    35  }
    36  
    37  func (r *XactMock) Snap() (snap *core.Snap) {
    38  	snap = &core.Snap{}
    39  	r.ToSnap(snap)
    40  	return
    41  }