github.com/voedger/voedger@v0.0.0-20240520144910-273e84102129/pkg/state/teststate/interface.go (about)

     1  /*
     2   * Copyright (c) 2024-present unTill Software Development Group B. V.
     3   * @author Michael Saigachenko
     4   */
     5  package teststate
     6  
     7  import (
     8  	"testing"
     9  
    10  	"github.com/voedger/voedger/pkg/appdef"
    11  	"github.com/voedger/voedger/pkg/iauthnz"
    12  	"github.com/voedger/voedger/pkg/istructs"
    13  	"github.com/voedger/voedger/pkg/state"
    14  )
    15  
    16  type NewEventCallback func(argBuilder istructs.IObjectBuilder, cudBuilder istructs.ICUD)
    17  type ViewValueCallback func(key istructs.IKeyBuilder, value istructs.IValueBuilder)
    18  type KeyBuilderCallback func(key istructs.IStateKeyBuilder)
    19  type ValueBuilderCallback func(value istructs.IStateValueBuilder)
    20  type HttpHandlerFunc func(req HttpRequest) (resp HttpResponse, err error)
    21  
    22  type ITestAPI interface {
    23  	// State
    24  	PutEvent(wsid istructs.WSID, name appdef.FullQName, cb NewEventCallback) (wLogOffs istructs.Offset, newRecordIds []istructs.RecordID)
    25  	PutView(testWSID istructs.WSID, entity appdef.FullQName, callback ViewValueCallback)
    26  	PutSecret(name string, secret []byte)
    27  	PutHttpHandler(HttpHandlerFunc)
    28  	PutFederationCmdHandler(state.FederationCommandHandler)
    29  	PutRequestSubject(principals []iauthnz.Principal, token string)
    30  	PutQuery(wsid istructs.WSID, name appdef.FullQName)
    31  
    32  	// Intent
    33  	RequireIntent(t *testing.T, storage appdef.QName, entity appdef.FullQName, kb KeyBuilderCallback) IIntentAssertions
    34  }
    35  
    36  type ITestState interface {
    37  	state.IState
    38  	ITestAPI
    39  }
    40  
    41  type IIntentAssertions interface {
    42  	Exists()
    43  	Equal(vb ValueBuilderCallback)
    44  }