github.com/mdaxf/iac@v0.0.0-20240519030858-58a061660378/framework/queue/queue_test.go (about) 1 package queue 2 3 import ( 4 "database/sql" 5 "reflect" 6 "sync" 7 "testing" 8 "time" 9 10 "github.com/mdaxf/iac/documents" 11 "github.com/mdaxf/iac-signalr/signalr" 12 ) 13 14 func TestNewMessageQueuebyExternal(t *testing.T) { 15 type args struct { 16 Id string 17 Name string 18 DB *sql.DB 19 DocDBconn *documents.DocDB 20 SignalRClient signalr.Client 21 } 22 tests := []struct { 23 name string 24 args args 25 want *MessageQueue 26 }{ 27 // TODO: Add test cases. 28 } 29 for _, tt := range tests { 30 t.Run(tt.name, func(t *testing.T) { 31 if got := NewMessageQueuebyExternal(tt.args.Id, tt.args.Name, tt.args.DB, tt.args.DocDBconn, tt.args.SignalRClient); !reflect.DeepEqual(got, tt.want) { 32 t.Errorf("NewMessageQueuebyExternal() = %v, want %v", got, tt.want) 33 } 34 }) 35 } 36 } 37 38 func TestMessageQueue_Push(t *testing.T) { 39 type args struct { 40 message Message 41 } 42 tests := []struct { 43 name string 44 mq *MessageQueue 45 args args 46 }{ 47 // TODO: Add test cases. 48 } 49 for _, tt := range tests { 50 t.Run(tt.name, func(t *testing.T) { 51 tt.mq.Push(tt.args.message) 52 }) 53 } 54 } 55 56 func TestMessageQueue_Pop(t *testing.T) { 57 tests := []struct { 58 name string 59 mq *MessageQueue 60 want Message 61 }{ 62 // TODO: Add test cases. 63 } 64 for _, tt := range tests { 65 t.Run(tt.name, func(t *testing.T) { 66 if got := tt.mq.Pop(); !reflect.DeepEqual(got, tt.want) { 67 t.Errorf("MessageQueue.Pop() = %v, want %v", got, tt.want) 68 } 69 }) 70 } 71 } 72 73 func TestMessageQueue_Length(t *testing.T) { 74 tests := []struct { 75 name string 76 mq *MessageQueue 77 want int 78 }{ 79 // TODO: Add test cases. 80 } 81 for _, tt := range tests { 82 t.Run(tt.name, func(t *testing.T) { 83 if got := tt.mq.Length(); got != tt.want { 84 t.Errorf("MessageQueue.Length() = %v, want %v", got, tt.want) 85 } 86 }) 87 } 88 } 89 90 func TestMessageQueue_Clear(t *testing.T) { 91 tests := []struct { 92 name string 93 mq *MessageQueue 94 }{ 95 // TODO: Add test cases. 96 } 97 for _, tt := range tests { 98 t.Run(tt.name, func(t *testing.T) { 99 tt.mq.Clear() 100 }) 101 } 102 } 103 104 func TestMessageQueue_WaitAndPop(t *testing.T) { 105 type args struct { 106 timeout time.Duration 107 } 108 tests := []struct { 109 name string 110 mq *MessageQueue 111 args args 112 want Message 113 }{ 114 // TODO: Add test cases. 115 } 116 for _, tt := range tests { 117 t.Run(tt.name, func(t *testing.T) { 118 if got := tt.mq.WaitAndPop(tt.args.timeout); !reflect.DeepEqual(got, tt.want) { 119 t.Errorf("MessageQueue.WaitAndPop() = %v, want %v", got, tt.want) 120 } 121 }) 122 } 123 } 124 125 func TestMessageQueue_WaitAndPopWithTimeout(t *testing.T) { 126 type args struct { 127 timeout time.Duration 128 } 129 tests := []struct { 130 name string 131 mq *MessageQueue 132 args args 133 want Message 134 }{ 135 // TODO: Add test cases. 136 } 137 for _, tt := range tests { 138 t.Run(tt.name, func(t *testing.T) { 139 if got := tt.mq.WaitAndPopWithTimeout(tt.args.timeout); !reflect.DeepEqual(got, tt.want) { 140 t.Errorf("MessageQueue.WaitAndPopWithTimeout() = %v, want %v", got, tt.want) 141 } 142 }) 143 } 144 } 145 146 func TestMessageQueue_Peek(t *testing.T) { 147 tests := []struct { 148 name string 149 mq *MessageQueue 150 want Message 151 }{ 152 // TODO: Add test cases. 153 } 154 for _, tt := range tests { 155 t.Run(tt.name, func(t *testing.T) { 156 if got := tt.mq.Peek(); !reflect.DeepEqual(got, tt.want) { 157 t.Errorf("MessageQueue.Peek() = %v, want %v", got, tt.want) 158 } 159 }) 160 } 161 } 162 163 func TestMessageQueue_execute(t *testing.T) { 164 tests := []struct { 165 name string 166 mq *MessageQueue 167 }{ 168 // TODO: Add test cases. 169 } 170 for _, tt := range tests { 171 t.Run(tt.name, func(t *testing.T) { 172 tt.mq.execute() 173 }) 174 } 175 } 176 177 func TestMessageQueue_waitForTerminationSignal(t *testing.T) { 178 tests := []struct { 179 name string 180 mq *MessageQueue 181 }{ 182 // TODO: Add test cases. 183 } 184 for _, tt := range tests { 185 t.Run(tt.name, func(t *testing.T) { 186 tt.mq.waitForTerminationSignal() 187 }) 188 } 189 } 190 191 func TestMessageQueue_processMessage(t *testing.T) { 192 type args struct { 193 message Message 194 } 195 tests := []struct { 196 name string 197 mq *MessageQueue 198 args args 199 wantErr bool 200 }{ 201 // TODO: Add test cases. 202 } 203 for _, tt := range tests { 204 t.Run(tt.name, func(t *testing.T) { 205 if err := tt.mq.processMessage(tt.args.message); (err != nil) != tt.wantErr { 206 t.Errorf("MessageQueue.processMessage() error = %v, wantErr %v", err, tt.wantErr) 207 } 208 }) 209 } 210 } 211 212 func TestMessageQueue_worker(t *testing.T) { 213 type args struct { 214 id int 215 jobs <-chan Message 216 wg *sync.WaitGroup 217 } 218 tests := []struct { 219 name string 220 mq *MessageQueue 221 args args 222 }{ 223 // TODO: Add test cases. 224 } 225 for _, tt := range tests { 226 t.Run(tt.name, func(t *testing.T) { 227 tt.mq.worker(tt.args.id, tt.args.jobs, tt.args.wg) 228 }) 229 } 230 }