worker/internal/privilegewc/consumer_test.go

41 lines
760 B
Go
Raw Permalink Normal View History

2024-04-07 09:47:46 +00:00
package privilegewc
import (
"context"
2025-02-24 17:58:46 +00:00
"gitea.pena/SQuiz/common/dal"
"gitea.pena/SQuiz/common/model"
2024-04-07 09:47:46 +00:00
"testing"
)
func TestProcessValidMessage(t *testing.T) {
ctx := context.Background()
2025-02-24 17:58:46 +00:00
d, err := dal.New(ctx, "host=localhost port=35432 user=squiz password=Redalert2 dbname=squiz sslmode=disable", nil)
2024-04-07 09:47:46 +00:00
if err != nil {
panic(err)
}
2025-02-24 17:58:46 +00:00
cfg, err := NewKafkaConsumerWorker(Config{}, nil, d)
2024-04-07 09:47:46 +00:00
if err != nil {
panic(err)
}
msg := []model.PrivilegeMessage{
{
PrivilegeID: "quizUnlimTime",
Amount: 1000,
},
{
PrivilegeID: "quizCnt",
Amount: 1000,
},
{
PrivilegeID: "squizHideBadge",
Amount: 1000,
},
}
err = cfg.processValidMessage(ctx, msg, "65f42bc9059f40a30ab21f68")
if err != nil {
panic(err)
}
}