MCPcopy Index your code
hub / github.com/devaccuracy/ledgerforge / newTestDataSource

Function newTestDataSource

ledger_test.go:40–67  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

38)
39
40func newTestDataSource() (database.IDataSource, sqlmock.Sqlmock, error) {
41 cnf := &config.Configuration{
42 Redis: config.RedisConfig{
43 Dns: testRedisAddr(),
44 },
45 Queue: config.QueueConfig{
46 WebhookQueue: "webhook_queue",
47 TransactionQueue: "transaction_queue",
48 IndexQueue: "index_queue",
49 NumberOfQueues: 1,
50 },
51 Server: config.ServerConfig{SecretKey: "some-secret"},
52 TokenizationSecret: "12345678901234567890123456789012",
53 AccountNumberGeneration: config.AccountNumberGenerationConfig{
54 HttpService: config.AccountGenerationHttpService{
55 Url: "http://example.com/generateAccount",
56 },
57 },
58 }
59
60 config.ConfigStore.Store(cnf)
61 db, mock, err := sqlmock.New()
62 if err != nil {
63 log.Printf("an error '%s' was not expected when opening a stub database Connection", err)
64 }
65 newCache := cache.NewCacheWithClient(redis.NewClient(&redis.Options{Addr: testRedisAddr()}))
66 return &database.Datasource{Conn: db, Cache: newCache}, mock, nil
67}
68
69func TestCreateLedger(t *testing.T) {
70 datasource, mock, err := newTestDataSource()

Calls 2

NewCacheWithClientFunction · 0.92
testRedisAddrFunction · 0.85

Tested by

no test coverage detected