MCPcopy Create free account
hub / github.com/devaccuracy/ledgerforge / TestRevokeAPIKey_Mock

Function TestRevokeAPIKey_Mock

transaction_test.go:6752–6787  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

6750}
6751
6752func TestRevokeAPIKey_Mock(t *testing.T) {
6753 cnf := &config.Configuration{
6754 Redis: config.RedisConfig{Dns: "localhost:6379"},
6755 Queue: config.QueueConfig{
6756 WebhookQueue: "webhook_queue",
6757 TransactionQueue: "transaction_queue",
6758 NumberOfQueues: 1,
6759 },
6760 }
6761 config.ConfigStore.Store(cnf)
6762
6763 t.Run("Success", func(t *testing.T) {
6764 mockDS := new(mocks.MockDataSource)
6765 keyID := "key_123"
6766 ownerID := "owner_123"
6767
6768 mockDS.On("RevokeAPIKey", mock.Anything, keyID, ownerID).Return(nil)
6769
6770 ledgerforge := &LedgerForge{datasource: mockDS, config: cnf}
6771 err := ledgerforge.RevokeAPIKey(context.Background(), keyID, ownerID)
6772
6773 assert.NoError(t, err)
6774 mockDS.AssertExpectations(t)
6775 })
6776
6777 t.Run("Key not found", func(t *testing.T) {
6778 mockDS := new(mocks.MockDataSource)
6779 mockDS.On("RevokeAPIKey", mock.Anything, "nonexistent", "owner").Return(fmt.Errorf("not found"))
6780
6781 ledgerforge := &LedgerForge{datasource: mockDS, config: cnf}
6782 err := ledgerforge.RevokeAPIKey(context.Background(), "nonexistent", "owner")
6783
6784 assert.Error(t, err)
6785 mockDS.AssertExpectations(t)
6786 })
6787}
6788
6789func TestGetAPIKeyByKey_Mock(t *testing.T) {
6790 cnf := &config.Configuration{

Callers

nothing calls this directly

Calls 2

RevokeAPIKeyMethod · 0.95
ErrorMethod · 0.45

Tested by

no test coverage detected