(t *testing.T)
| 6750 | } |
| 6751 | |
| 6752 | func 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 | |
| 6789 | func TestGetAPIKeyByKey_Mock(t *testing.T) { |
| 6790 | cnf := &config.Configuration{ |
nothing calls this directly
no test coverage detected