Compare commits
No commits in common. "7fe8f0b7d578d1541207a8604a909c08b8124a68" and "b6d24bf92938fce74eada07f3e454fcf71e32fa0" have entirely different histories.
7fe8f0b7d5
...
b6d24bf929
@ -1782,38 +1782,5 @@ func TestConfirmPin(t *testing.T) {
|
|||||||
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
func TestSetVoucher(t *testing.T) {
|
|
||||||
mockDataStore := new(mocks.MockUserDataStore)
|
|
||||||
|
|
||||||
sessionId := "session123"
|
|
||||||
ctx := context.WithValue(context.Background(), "SessionId", sessionId)
|
|
||||||
|
|
||||||
temporarySym := []byte("tempSym")
|
|
||||||
temporaryBal := []byte("tempBal")
|
|
||||||
|
|
||||||
// Set expectations for the mock data store
|
|
||||||
mockDataStore.On("ReadEntry", ctx, sessionId, utils.DATA_TEMPORARY_SYM).Return(temporarySym, nil)
|
|
||||||
mockDataStore.On("ReadEntry", ctx, sessionId, utils.DATA_TEMPORARY_BAL).Return(temporaryBal, nil)
|
|
||||||
mockDataStore.On("WriteEntry", ctx, sessionId, utils.DATA_ACTIVE_SYM, temporarySym).Return(nil)
|
|
||||||
mockDataStore.On("WriteEntry", ctx, sessionId, utils.DATA_ACTIVE_BAL, temporaryBal).Return(nil)
|
|
||||||
mockDataStore.On("WriteEntry", ctx, sessionId, utils.DATA_TEMPORARY_SYM, []byte("")).Return(nil)
|
|
||||||
mockDataStore.On("WriteEntry", ctx, sessionId, utils.DATA_TEMPORARY_BAL, []byte("")).Return(nil)
|
|
||||||
|
|
||||||
h := &Handlers{
|
|
||||||
userdataStore: mockDataStore,
|
|
||||||
}
|
|
||||||
|
|
||||||
// Call the method under test
|
|
||||||
res, err := h.SetVoucher(ctx, "someSym", []byte{})
|
|
||||||
|
|
||||||
// Assert that no errors occurred
|
|
||||||
assert.NoError(t, err)
|
|
||||||
|
|
||||||
// Assert that the result content is correct
|
|
||||||
assert.Equal(t, string(temporarySym), res.Content)
|
|
||||||
|
|
||||||
// Assert that expectations were met
|
|
||||||
mockDataStore.AssertExpectations(t)
|
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,6 @@ func (m *MockAccountService) CheckAccountStatus(trackingId string) (string, erro
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *MockAccountService) FetchVouchers(publicKey string) (*models.VoucherHoldingResponse, error) {
|
func (m *MockAccountService) FetchVouchers(publicKey string) (*models.VoucherHoldingResponse, error) {
|
||||||
args := m.Called(publicKey)
|
args := m.Called()
|
||||||
return args.Get(0).(*models.VoucherHoldingResponse), args.Error(1)
|
return args.Get(0).(*models.VoucherHoldingResponse), args.Error(1)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user