From 6bf60ee17bcdd0bf9a105346aa2763818d8af485 Mon Sep 17 00:00:00 2001 From: Quanzheng Long Date: Mon, 22 May 2023 14:28:13 -0700 Subject: [PATCH] Add readme --- iwftest/README.md | 59 +---------------------------------------------- 1 file changed, 1 insertion(+), 58 deletions(-) diff --git a/iwftest/README.md b/iwftest/README.md index 326ac83..0ff7921 100644 --- a/iwftest/README.md +++ b/iwftest/README.md @@ -9,62 +9,5 @@ The APIs are generated by the below commands: ## Usage -See the [samples](https://github.com/indeedeng/iwf-golang-samples) for more details: +See the [example](./example) for more details. -```go -package subscription - -import ( - "github.com/golang/mock/gomock" - "github.com/indeedeng/iwf-golang-sdk/iwf" - "github.com/indeedeng/iwf-golang-sdk/iwftest" - "github.com/stretchr/testify/assert" - "testing" - "time" -) - -var mockWfCtx *iwftest.MockWorkflowContext -var mockPersistence *iwftest.MockPersistence -var mockCommunication *iwftest.MockCommunication -var emptyCmdResults = iwf.CommandResults{} -var emptyObj = iwftest.NewTestObject(nil) -var mockSvc *MockMyService - -func beforeEach(t *testing.T) { - ctrl := gomock.NewController(t) - - mockSvc = NewMockMyService(ctrl) - mockWfCtx = iwftest.NewMockWorkflowContext(ctrl) - mockPersistence = iwftest.NewMockPersistence(ctrl) - mockCommunication = iwftest.NewMockCommunication(ctrl) -} - - -func TestInitState_WaitUntil(t *testing.T) { - beforeEach(t) - - state := NewInitState() - - mockPersistence.EXPECT().SetDataObject(keyCustomer, testCustomer) - cmdReq, err := state.WaitUntil(mockWfCtx, testCustomerObj, mockPersistence, mockCommunication) - assert.Nil(t, err) - assert.Equal(t, iwf.EmptyCommandRequest(), cmdReq) -} - - -func TestTrialState_WaitUntil(t *testing.T) { - beforeEach(t) - - state := NewTrialState(mockSvc) - - mockSvc.EXPECT().sendEmail(testCustomer.Email, gomock.Any(), gomock.Any()) - mockPersistence.EXPECT().GetDataObject(keyCustomer, gomock.Any()).SetArg(1, testCustomer) - cmdReq, err := state.WaitUntil(mockWfCtx, emptyObj, mockPersistence, mockCommunication) - assert.Nil(t, err) - firingTime := cmdReq.Commands[0].TimerCommand.FiringUnixTimestampSeconds - assert.Equal(t, iwf.AllCommandsCompletedRequest( - iwf.NewTimerCommand("", time.Unix(firingTime, 0)), - ), cmdReq) -} - -```