| 1 | package serverscip-go gomod github.com/valinurovam/garagemq . `github.com/valinurovam/garagemq/server`/ |
| 2 | |
| 3 | import ( |
| 4 | "testingscip-go gomod github.com/golang/go/src go1.12 testing/" |
| 5 | "timescip-go gomod github.com/golang/go/src go1.12 time/" |
| 6 | |
| 7 | "github.com/streadway/amqpscip-go gomod github.com/streadway/amqp 75d898a42a94 `github.com/streadway/amqp`/" |
| 8 | ) |
| 9 | |
| 10 | func Test_Confirm_Successscip-go gomod github.com/valinurovam/garagemq . `github.com/valinurovam/garagemq/server`/Test_Confirm_Success().(t *testingscip-go gomod github.com/golang/go/src go1.12 testing/.Tscip-go gomod github.com/golang/go/src go1.12 testing/T#) { |
| 11 | sc, _ := getNewSCscip-go gomod github.com/valinurovam/garagemq . `github.com/valinurovam/garagemq/server`/getNewSC().(getDefaultTestConfigscip-go gomod github.com/valinurovam/garagemq . `github.com/valinurovam/garagemq/server`/getDefaultTestConfig().()) |
| 12 | defer sc.cleanscip-go gomod github.com/valinurovam/garagemq . `github.com/valinurovam/garagemq/server`/ServerClient#clean().() |
| 13 | ch, _ := sc.clientscip-go gomod github.com/valinurovam/garagemq . `github.com/valinurovam/garagemq/server`/ServerClient#client..Channelscip-go gomod github.com/streadway/amqp 75d898a42a94 `github.com/streadway/amqp`/Connection#Channel().() |
| 14 | err := ch.Confirmscip-go gomod github.com/streadway/amqp 75d898a42a94 `github.com/streadway/amqp`/Channel#Confirm().(false) |
| 15 | |
| 16 | if err != nil { |
| 17 | t.Errorscip-go gomod github.com/golang/go/src go1.12 testing/common#Error().(err) |
| 18 | } |
| 19 | |
| 20 | channel := getServerChannelscip-go gomod github.com/valinurovam/garagemq . `github.com/valinurovam/garagemq/server`/getServerChannel().(sc, 1) |
| 21 | if channel.confirmModescip-go gomod github.com/valinurovam/garagemq . `github.com/valinurovam/garagemq/server`/Channel#confirmMode. == false { |
| 22 | t.Errorscip-go gomod github.com/golang/go/src go1.12 testing/common#Error().("Channel non confirm mode") |
| 23 | } |
| 24 | } |
| 25 | |
| 26 | func Test_ConfirmReceive_Acks_Successscip-go gomod github.com/valinurovam/garagemq . `github.com/valinurovam/garagemq/server`/Test_ConfirmReceive_Acks_Success().(t *testingscip-go gomod github.com/golang/go/src go1.12 testing/.Tscip-go gomod github.com/golang/go/src go1.12 testing/T#) { |
| 27 | sc, _ := getNewSCscip-go gomod github.com/valinurovam/garagemq . `github.com/valinurovam/garagemq/server`/getNewSC().(getDefaultTestConfigscip-go gomod github.com/valinurovam/garagemq . `github.com/valinurovam/garagemq/server`/getDefaultTestConfig().()) |
| 28 | defer sc.cleanscip-go gomod github.com/valinurovam/garagemq . `github.com/valinurovam/garagemq/server`/ServerClient#clean().() |
| 29 | ch, _ := sc.clientscip-go gomod github.com/valinurovam/garagemq . `github.com/valinurovam/garagemq/server`/ServerClient#client..Channelscip-go gomod github.com/streadway/amqp 75d898a42a94 `github.com/streadway/amqp`/Connection#Channel().() |
| 30 | ch.Confirmscip-go gomod github.com/streadway/amqp 75d898a42a94 `github.com/streadway/amqp`/Channel#Confirm().(false) |
| 31 | |
| 32 | msgCount := 10 |
| 33 | acks := make(chan uint64, msgCount) |
| 34 | nacks := make(chan uint64, msgCount) |
| 35 | ch.NotifyConfirmscip-go gomod github.com/streadway/amqp 75d898a42a94 `github.com/streadway/amqp`/Channel#NotifyConfirm().(acks, nacks) |
| 36 | |
| 37 | queue, _ := ch.QueueDeclarescip-go gomod github.com/streadway/amqp 75d898a42a94 `github.com/streadway/amqp`/Channel#QueueDeclare().(t.Namescip-go gomod github.com/golang/go/src go1.12 testing/common#Name().(), false, false, false, false, emptyTablescip-go gomod github.com/valinurovam/garagemq . `github.com/valinurovam/garagemq/server`/emptyTable.) |
| 38 | |
| 39 | for i := 0; i < msgCount; i++ { |
| 40 | ch.Publishscip-go gomod github.com/streadway/amqp 75d898a42a94 `github.com/streadway/amqp`/Channel#Publish().("", queue.Namescip-go gomod github.com/streadway/amqp 75d898a42a94 `github.com/streadway/amqp`/Queue#Name., false, false, amqpscip-go gomod github.com/streadway/amqp 75d898a42a94 `github.com/streadway/amqp`/.Publishingscip-go gomod github.com/streadway/amqp 75d898a42a94 `github.com/streadway/amqp`/Publishing#{ContentTypescip-go gomod github.com/streadway/amqp 75d898a42a94 `github.com/streadway/amqp`/Publishing#ContentType.: "text/plain", Bodyscip-go gomod github.com/streadway/amqp 75d898a42a94 `github.com/streadway/amqp`/Publishing#Body.: []byte("test")}) |
| 41 | } |
| 42 | |
| 43 | tick := timescip-go gomod github.com/golang/go/src go1.12 time/.Afterscip-go gomod github.com/golang/go/src go1.12 time/After().(50 * timescip-go gomod github.com/golang/go/src go1.12 time/.Millisecondscip-go gomod github.com/golang/go/src go1.12 time/Millisecond.) |
| 44 | confirmsCount := 0 |
| 45 | leave := false |
| 46 | for { |
| 47 | select { |
| 48 | case <-acks: |
| 49 | confirmsCount++ |
| 50 | case <-nacks: |
| 51 | confirmsCount-- |
| 52 | case <-tick: |
| 53 | leave = true |
| 54 | default: |
| 55 | |
| 56 | } |
| 57 | if leave { |
| 58 | break |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | if confirmsCount != msgCount { |
| 63 | t.Errorfscip-go gomod github.com/golang/go/src go1.12 testing/common#Errorf().("Expected %d confirms, actual %d", msgCount, confirmsCount) |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | func Test_ConfirmReceive_Acks_NoRoute_Successscip-go gomod github.com/valinurovam/garagemq . `github.com/valinurovam/garagemq/server`/Test_ConfirmReceive_Acks_NoRoute_Success().(t *testingscip-go gomod github.com/golang/go/src go1.12 testing/.Tscip-go gomod github.com/golang/go/src go1.12 testing/T#) { |
| 68 | sc, _ := getNewSCscip-go gomod github.com/valinurovam/garagemq . `github.com/valinurovam/garagemq/server`/getNewSC().(getDefaultTestConfigscip-go gomod github.com/valinurovam/garagemq . `github.com/valinurovam/garagemq/server`/getDefaultTestConfig().()) |
| 69 | defer sc.cleanscip-go gomod github.com/valinurovam/garagemq . `github.com/valinurovam/garagemq/server`/ServerClient#clean().() |
| 70 | ch, _ := sc.clientscip-go gomod github.com/valinurovam/garagemq . `github.com/valinurovam/garagemq/server`/ServerClient#client..Channelscip-go gomod github.com/streadway/amqp 75d898a42a94 `github.com/streadway/amqp`/Connection#Channel().() |
| 71 | ch.Confirmscip-go gomod github.com/streadway/amqp 75d898a42a94 `github.com/streadway/amqp`/Channel#Confirm().(false) |
| 72 | |
| 73 | msgCount := 10 |
| 74 | acks := make(chan uint64, msgCount) |
| 75 | nacks := make(chan uint64, msgCount) |
| 76 | ch.NotifyConfirmscip-go gomod github.com/streadway/amqp 75d898a42a94 `github.com/streadway/amqp`/Channel#NotifyConfirm().(acks, nacks) |
| 77 | |
| 78 | ch.QueueDeclarescip-go gomod github.com/streadway/amqp 75d898a42a94 `github.com/streadway/amqp`/Channel#QueueDeclare().(t.Namescip-go gomod github.com/golang/go/src go1.12 testing/common#Name().(), false, false, false, false, emptyTablescip-go gomod github.com/valinurovam/garagemq . `github.com/valinurovam/garagemq/server`/emptyTable.) |
| 79 | |
| 80 | for i := 0; i < msgCount; i++ { |
| 81 | ch.Publishscip-go gomod github.com/streadway/amqp 75d898a42a94 `github.com/streadway/amqp`/Channel#Publish().("", "bad-route", false, false, amqpscip-go gomod github.com/streadway/amqp 75d898a42a94 `github.com/streadway/amqp`/.Publishingscip-go gomod github.com/streadway/amqp 75d898a42a94 `github.com/streadway/amqp`/Publishing#{ContentTypescip-go gomod github.com/streadway/amqp 75d898a42a94 `github.com/streadway/amqp`/Publishing#ContentType.: "text/plain", Bodyscip-go gomod github.com/streadway/amqp 75d898a42a94 `github.com/streadway/amqp`/Publishing#Body.: []byte("test")}) |
| 82 | } |
| 83 | |
| 84 | tick := timescip-go gomod github.com/golang/go/src go1.12 time/.Afterscip-go gomod github.com/golang/go/src go1.12 time/After().(50 * timescip-go gomod github.com/golang/go/src go1.12 time/.Millisecondscip-go gomod github.com/golang/go/src go1.12 time/Millisecond.) |
| 85 | confirmsCount := 0 |
| 86 | leave := false |
| 87 | for { |
| 88 | select { |
| 89 | case <-acks: |
| 90 | confirmsCount++ |
| 91 | case <-nacks: |
| 92 | confirmsCount-- |
| 93 | case <-tick: |
| 94 | leave = true |
| 95 | default: |
| 96 | |
| 97 | } |
| 98 | if leave { |
| 99 | break |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | if confirmsCount != msgCount { |
| 104 | t.Errorfscip-go gomod github.com/golang/go/src go1.12 testing/common#Errorf().("Expected %d confirms, actual %d", msgCount, confirmsCount) |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | func Test_ConfirmReceive_Acks_Persistent_Successscip-go gomod github.com/valinurovam/garagemq . `github.com/valinurovam/garagemq/server`/Test_ConfirmReceive_Acks_Persistent_Success().(t *testingscip-go gomod github.com/golang/go/src go1.12 testing/.Tscip-go gomod github.com/golang/go/src go1.12 testing/T#) { |
| 109 | sc, _ := getNewSCscip-go gomod github.com/valinurovam/garagemq . `github.com/valinurovam/garagemq/server`/getNewSC().(getDefaultTestConfigscip-go gomod github.com/valinurovam/garagemq . `github.com/valinurovam/garagemq/server`/getDefaultTestConfig().()) |
| 110 | defer sc.cleanscip-go gomod github.com/valinurovam/garagemq . `github.com/valinurovam/garagemq/server`/ServerClient#clean().() |
| 111 | ch, _ := sc.clientscip-go gomod github.com/valinurovam/garagemq . `github.com/valinurovam/garagemq/server`/ServerClient#client..Channelscip-go gomod github.com/streadway/amqp 75d898a42a94 `github.com/streadway/amqp`/Connection#Channel().() |
| 112 | ch.Confirmscip-go gomod github.com/streadway/amqp 75d898a42a94 `github.com/streadway/amqp`/Channel#Confirm().(false) |
| 113 | |
| 114 | msgCount := 10 |
| 115 | acks := make(chan uint64, msgCount) |
| 116 | nacks := make(chan uint64, msgCount) |
| 117 | ch.NotifyConfirmscip-go gomod github.com/streadway/amqp 75d898a42a94 `github.com/streadway/amqp`/Channel#NotifyConfirm().(acks, nacks) |
| 118 | |
| 119 | queue, _ := ch.QueueDeclarescip-go gomod github.com/streadway/amqp 75d898a42a94 `github.com/streadway/amqp`/Channel#QueueDeclare().(t.Namescip-go gomod github.com/golang/go/src go1.12 testing/common#Name().(), true, false, false, false, emptyTablescip-go gomod github.com/valinurovam/garagemq . `github.com/valinurovam/garagemq/server`/emptyTable.) |
| 120 | |
| 121 | for i := 0; i < msgCount; i++ { |
| 122 | ch.Publishscip-go gomod github.com/streadway/amqp 75d898a42a94 `github.com/streadway/amqp`/Channel#Publish().("", queue.Namescip-go gomod github.com/streadway/amqp 75d898a42a94 `github.com/streadway/amqp`/Queue#Name., false, false, amqpscip-go gomod github.com/streadway/amqp 75d898a42a94 `github.com/streadway/amqp`/.Publishingscip-go gomod github.com/streadway/amqp 75d898a42a94 `github.com/streadway/amqp`/Publishing#{ContentTypescip-go gomod github.com/streadway/amqp 75d898a42a94 `github.com/streadway/amqp`/Publishing#ContentType.: "text/plain", Bodyscip-go gomod github.com/streadway/amqp 75d898a42a94 `github.com/streadway/amqp`/Publishing#Body.: []byte("test"), DeliveryModescip-go gomod github.com/streadway/amqp 75d898a42a94 `github.com/streadway/amqp`/Publishing#DeliveryMode.: amqpscip-go gomod github.com/streadway/amqp 75d898a42a94 `github.com/streadway/amqp`/.Persistentscip-go gomod github.com/streadway/amqp 75d898a42a94 `github.com/streadway/amqp`/Persistent.}) |
| 123 | } |
| 124 | |
| 125 | tick := timescip-go gomod github.com/golang/go/src go1.12 time/.Afterscip-go gomod github.com/golang/go/src go1.12 time/After().(50 * timescip-go gomod github.com/golang/go/src go1.12 time/.Millisecondscip-go gomod github.com/golang/go/src go1.12 time/Millisecond.) |
| 126 | confirmsCount := 0 |
| 127 | leave := false |
| 128 | for { |
| 129 | select { |
| 130 | case <-acks: |
| 131 | confirmsCount++ |
| 132 | case <-nacks: |
| 133 | confirmsCount-- |
| 134 | case <-tick: |
| 135 | leave = true |
| 136 | default: |
| 137 | |
| 138 | } |
| 139 | if leave { |
| 140 | break |
| 141 | } |
| 142 | } |
| 143 | |
| 144 | if confirmsCount != msgCount { |
| 145 | t.Errorfscip-go gomod github.com/golang/go/src go1.12 testing/common#Errorf().("Expected %d confirms, actual %d", msgCount, confirmsCount) |
| 146 | } |
| 147 | } |