(t *testing.T)
| 30 | ) |
| 31 | |
| 32 | func TestEnqueueImmediateTransactionSuccess(t *testing.T) { |
| 33 | cnf := &config.Configuration{ |
| 34 | Redis: config.RedisConfig{ |
| 35 | Dns: testRedisAddr(), |
| 36 | }, |
| 37 | Queue: config.QueueConfig{ |
| 38 | WebhookQueue: "webhook_queue", |
| 39 | NumberOfQueues: 1, |
| 40 | }, |
| 41 | } |
| 42 | config.ConfigStore.Store(cnf) |
| 43 | |
| 44 | redisOption, err := redis_db.ParseRedisURL(testRedisAddr(), false) |
| 45 | if err != nil { |
| 46 | log.Fatalf("Error parsing Redis URL: %v", err) |
| 47 | } |
| 48 | queueOptions := asynq.RedisClientOpt{Addr: redisOption.Addr, Password: redisOption.Password, DB: redisOption.DB, TLSConfig: redisOption.TLSConfig} |
| 49 | client := asynq.NewClient(queueOptions) |
| 50 | inspector := asynq.NewInspector(queueOptions) |
| 51 | |
| 52 | q := NewQueue(cnf, client) |
| 53 | q.Inspector = inspector |
| 54 | |
| 55 | transaction := getTransactionMock(100, false) |
| 56 | _, err = json.Marshal(transaction) |
| 57 | assert.NoError(t, err) |
| 58 | |
| 59 | err = q.Enqueue(context.Background(), &transaction) |
| 60 | assert.NoError(t, err) |
| 61 | |
| 62 | task, err := inspector.GetTaskInfo(cnf.Queue.WebhookQueue, transaction.TransactionID) |
| 63 | if err != nil { |
| 64 | return |
| 65 | } |
| 66 | |
| 67 | assert.Equal(t, "tx_123", task.ID) |
| 68 | } |
| 69 | |
| 70 | func TestEnqueueScheduledTransaction(t *testing.T) { |
| 71 | conf := &config.Configuration{ |
nothing calls this directly
no test coverage detected