package msgQueue

import (
	"sparrow/pkg/protocol"
	"sparrow/pkg/queue"
	"sparrow/pkg/server"
	"testing"
)

func TestNewRabbitMqProducer(t *testing.T) {
	server.InitLog("test", "debug")
	admin := NewRabbitMessageQueueAdmin(&RabbitMqSettings{
		Host:"amqp://guest:guest@localhost:5672/",
	}, nil)

	producer := NewRabbitMqProducer(admin, "test.lijian")
	tpi :=&queue.TopicPartitionInfo{
		Topic:       "ruleengine",
		TenantId:    "111",
		Partition:   1,
		MyPartition: false,
	}
	msg, err := queue.NewGobQueueMessage(&protocol.Message{
		QueueName:  "111",
		Id:         "1111",
		Ts:         nil,
		Type:       "1213",
		Data:       "123213",
		RuleChanId: "123",
		RuleNodeId: "123123",
		Callback:   nil,
		MetaData:   nil,
		Originator: "",
	})
	if err != nil {
		t.Error(err)
	}

	err = producer.Send(tpi, msg, nil)
	if err != nil {
		t.Error(err)
	}
}
