title: How do I verify publisher acknowledge behavior
body: <p>I am writing a go program with publisher confirms, and I want to verify the behavior when a message can be delivered/not be delivered to the broker.</p>
  
  <p>I am doing this from an integration test that sets up a queue, and asks my system code to send to that queue name. Verifying the behavior for publisher ack is no problem, but I cannot provoke a situation that results in a publisher nack.</p>
  
  <p>I try to send a message to a non-existing queue with the following piece of code:</p>
  
  <pre><code>connection, err := amqp.Dial("amqp://localhost")
  if err != nil {
      panic(err)
  }
  defer connection.Close()
  channel, err := connection.Channel()
  if err != nil {
      panic(err)
  }
  err = channel.Confirm(false)
  if err != nil {
      panic(err)
  }
  pubAck, pubNack := channel.NotifyConfirm(make(chan uint64, 1), make(chan uint64, 1))
  fmt.Println("Publish to queue: ", queueName)
  msg := amqp.Publishing{
      Body: []byte("Hello")}
  err = channel.Publish("", queueName, true, true, msg)
  if err != nil {
      panic(err)
  }
  select {
  case &lt;-pubAck:
      fmt.Println("Ack")
  case &lt;-pubNack:
      fmt.Println("NAck")
  }
  </code></pre>
  
  <p>The queue name is indeed a non existing queue, and executing <code>sudo rabbitmqctl list_queues</code> shows that the list of queues is empty.</p>
  
  <p>But it still prints "Ack"</p>
  
  <p>I have set both <code>mandatory</code> and <code>immediate</code> to true</p>
  
  <blockquote>
    <p>Publishings can be undeliverable when the mandatory flag is
    true and no queue is bound that matches the routing key, or when the
    immediate flag is true and no consumer on the matched queue is ready
    to accept the delivery</p>
  </blockquote>
  
  <p>Is my approach for sending to a non-existing queue a wrong approach, and is there another way I can send a message that will provoke a publisher nack?</p>