|
@@ -20,8 +20,11 @@ func (callerIdentifier *CallerIdentifier) Identifier() string {
|
|
|
return callerIdentifier.CallerIdentifier
|
|
|
}
|
|
|
|
|
|
-var bindingCallerIdentifier = &CallerIdentifier{CallerIdentifier: ""}
|
|
|
-var itemCallerIdentifier = &CallerIdentifier{CallerIdentifier: ""}
|
|
|
+var bindingCallerIdentifier = &CallerIdentifier{CallerIdentifier: "binding"}
|
|
|
+var itemCallerIdentifier = &CallerIdentifier{CallerIdentifier: "item"}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
func TestMqttBinding(t *testing.T) {
|
|
|
err := mqtt_binding.Init("test_prefix", &mqtt_client.MqttClientOptions{
|
|
@@ -51,6 +54,7 @@ func TestMqttBinding(t *testing.T) {
|
|
|
BusinessFunc: func(c *mqtt_client.MqttClient, inputModel struct {
|
|
|
Time string `json:"time"`
|
|
|
}) (map[string]interface{}, error) {
|
|
|
+ panic("11111111")
|
|
|
fmt.Printf("Received: %v\n", inputModel)
|
|
|
|
|
|
return map[string]interface{}{
|
|
@@ -75,9 +79,9 @@ func TestMqttBinding(t *testing.T) {
|
|
|
SetWill("test-client/will", "dead", 2, true).
|
|
|
SetOnConnectHandler(func(client mqtt.Client) {
|
|
|
replyTopic := "test_prefix/test/test-topic/reply"
|
|
|
- if itemCallerIdentifier.Identifier() != "" {
|
|
|
+ if itemCallerIdentifier != nil {
|
|
|
replyTopic = "test_prefix/test/test-topic/" + itemCallerIdentifier.Identifier() + "/reply"
|
|
|
- } else if bindingCallerIdentifier.Identifier() != "" {
|
|
|
+ } else if bindingCallerIdentifier != nil {
|
|
|
replyTopic = "test_prefix/test/test-topic/" + bindingCallerIdentifier.Identifier() + "/reply"
|
|
|
}
|
|
|
|
|
@@ -90,7 +94,8 @@ func TestMqttBinding(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
sendMap := map[string]any{
|
|
|
- "time": time.Now().Format(time.DateTime),
|
|
|
+ "callerIdentifier": "test",
|
|
|
+ "time": time.Now().Format(time.DateTime),
|
|
|
}
|
|
|
|
|
|
if itemCallerIdentifier.Identifier() != "" {
|