How to use Error method of utils Package

Best Rod code snippet using utils.Error

ezmq_subscriber_test.go

Source:ezmq_subscriber_test.go Github

copy

Full Screen

...22 "fmt"23 "testing"24 "time"25)26var subResult ezmq.EZMQErrorCode27var subApiInstance *ezmq.EZMQAPI28var subscriber *ezmq.EZMQSubscriber29var published = make(chan bool, 1)30var eventCount = 031func subCB(ezmqMsg ezmq.EZMQMessage) {32 fmt.Printf("\nsubCB")33 eventCount++34}35func subTopicCB(topic string, ezmqMsg ezmq.EZMQMessage) {36 fmt.Printf("\nsubTopicCB")37 eventCount++38}39func TestGetSubInstance(t *testing.T) {40 subApiInstance = ezmq.GetInstance()41 subApiInstance.Initialize()42 subscriber = ezmq.GetEZMQSubscriber(utils.Ip, utils.Port, subCB, subTopicCB)43 if nil == subscriber {44 t.Errorf("\nSubscriber instance is NULL")45 }46 subApiInstance.Terminate()47}48func TestGeSubInstanceNegative(t *testing.T) {49 subscriber = nil50 subscriber = ezmq.GetEZMQSubscriber(utils.Ip, utils.Port, subCB, subTopicCB)51 if nil != subscriber {52 t.Errorf("\nSubscriber instace is NULL")53 }54 subApiInstance = ezmq.GetInstance()55 subApiInstance.Initialize()56}57func TestSubscriberStart(t *testing.T) {58 subscriber = ezmq.GetEZMQSubscriber(utils.Ip, utils.Port, subCB, subTopicCB)59 if nil == subscriber {60 t.Errorf("\nSubscriber instance is NULL")61 }62 subResult = subscriber.Start()63 if subResult != 0 {64 t.Errorf("\nError while starting subscriber\n")65 }66 subResult = subscriber.Stop()67 if subResult != 0 {68 t.Errorf("\nError while Stopping subscriber")69 }70}71func TestSubscribe1(t *testing.T) {72 subscriber = ezmq.GetEZMQSubscriber(utils.Ip, utils.Port, subCB, subTopicCB)73 if nil == subscriber {74 t.Errorf("\nSubscriber instance is NULL")75 }76 subResult = subscriber.Start()77 if subResult != 0 {78 t.Errorf("\nError while starting subscriber\n")79 }80 subResult = subscriber.Subscribe()81 if subResult != 0 {82 t.Errorf("\nError while subscribing\n")83 }84 subResult = subscriber.Stop()85 if subResult != 0 {86 t.Errorf("\nError while Stopping subscriber")87 }88}89func TestSubscribe2(t *testing.T) {90 subscriber = ezmq.GetEZMQSubscriber(utils.Ip, utils.Port, subCB, subTopicCB)91 if nil == subscriber {92 t.Errorf("\nSubscriber instance is NULL")93 }94 subResult = subscriber.Start()95 if subResult != 0 {96 t.Errorf("\nError while starting subscriber\n")97 }98 subResult = subscriber.SubscribeForTopic(utils.Topic)99 if subResult != 0 {100 t.Errorf("\nError while subscribing on Utils.Topic\n")101 }102 subResult = subscriber.Stop()103 if subResult != 0 {104 t.Errorf("\nError while Stopping subscriber")105 }106}107func publish() {108 var pubApiInstance *ezmq.EZMQAPI109 pubApiInstance = ezmq.GetInstance()110 pubApiInstance.Initialize()111 publisher = ezmq.GetEZMQPublisher(utils.Port, startCB, stopCB, errorCB)112 publisher.Start()113 var event ezmq.Event = utils.GetEvent()114 for i := 0; i < 5; i++ {115 time.Sleep(500 * time.Millisecond)116 publisher.PublishOnTopic(utils.Topic, event)117 }118 publisher.Stop()119 published <- true120}121func TestSubscribe3(t *testing.T) {122 subscriber = ezmq.GetEZMQSubscriber(utils.Ip, utils.Port, subCB, subTopicCB)123 if nil == subscriber {124 t.Errorf("\nSubscriber instance is NULL")125 }126 subResult = subscriber.Start()127 if subResult != 0 {128 t.Errorf("\nError while starting subscriber\n")129 }130 subResult = subscriber.SubscribeForTopic(utils.Topic)131 if subResult != 0 {132 t.Errorf("\nError while subscribing on Utils.Topic\n")133 }134 go publish()135 <-published // wait for publisher to stop136 subResult = subscriber.Stop()137 if subResult != 0 {138 t.Errorf("\nError while Stopping subscriber")139 }140}141func TestSubscribe4(t *testing.T) {142 subscriber = ezmq.GetEZMQSubscriber(utils.Ip, utils.Port, subCB, subTopicCB)143 if nil == subscriber {144 t.Errorf("\nSubscriber instance is NULL")145 }146 subResult = subscriber.Start()147 if subResult != 0 {148 t.Errorf("\nError while starting subscriber\n")149 }150 topicList := List.New()151 subResult = subscriber.SubscribeForTopicList(*topicList)152 if subResult != 2 {153 t.Errorf("\nWrong error code\n")154 }155 e1 := topicList.PushFront("topic1")156 _ = e1157 e2 := topicList.PushFront("topic2")158 _ = e2159 subResult = subscriber.SubscribeForTopicList(*topicList)160 if subResult != 0 {161 t.Errorf("\nError while subscribing on Utils.Topic list\n")162 }163 e3 := topicList.PushFront("")164 _ = e3165 subResult = subscriber.SubscribeForTopicList(*topicList)166 if subResult == 0 {167 t.Errorf("\nSubscribd on invalid Utils.Topic list\n")168 }169 subResult = subscriber.Stop()170 if subResult != 0 {171 t.Errorf("\nError while Stopping subscriber")172 }173}174func TestSubscribeTopic(t *testing.T) {175 subscriber = ezmq.GetEZMQSubscriber(utils.Ip, utils.Port, subCB, subTopicCB)176 if nil == subscriber {177 t.Errorf("\nSubscriber instance is NULL")178 }179 subResult = subscriber.Start()180 if subResult != 0 {181 t.Errorf("\nError while starting subscriber\n")182 }183 var testingTopic string = ""184 // Empty Utils.Topic test185 if 2 != (subscriber.SubscribeForTopic(testingTopic)) {186 t.Errorf("\nSubscribed on invalid Utils.Topic\n")187 }188 // Alphabet test189 testingTopic = "Utils.Topic"190 if 0 != (subscriber.SubscribeForTopic(testingTopic)) {191 t.Errorf("\nSubscription failed for valid Utils.Topic\n")192 }193 // Numeric test194 testingTopic = "123"195 if 0 != (subscriber.SubscribeForTopic(testingTopic)) {196 t.Errorf("\nSubscription failed for valid Utils.Topic\n")197 }198 // Alpha-Numeric test199 testingTopic = "1a2b3"200 if 0 != (subscriber.SubscribeForTopic(testingTopic)) {201 t.Errorf("\nSubscription failed for valid Utils.Topic\n")202 }203 // Alphabet forward slash test204 testingTopic = "Utils.Topic/"205 if 0 != (subscriber.SubscribeForTopic(testingTopic)) {206 t.Errorf("\nSubscription failed for valid Utils.Topic\n")207 }208 // Alphabet-Numeric, forward slash test209 testingTopic = "Utils.Topic/13/4jtjos/"210 if 0 != (subscriber.SubscribeForTopic(testingTopic)) {211 t.Errorf("\nSubscription failed for valid Utils.Topic\n")212 }213 // Alphabet-Numeric, forward slash test214 testingTopic = "123a/1this3/4jtjos"215 if 0 != (subscriber.SubscribeForTopic(testingTopic)) {216 t.Errorf("\nSubscription failed for valid Utils.Topic\n")217 }218 // Alphabet, backslash test219 testingTopic = "Utils.Topic\";"220 if 2 != (subscriber.SubscribeForTopic(testingTopic)) {221 t.Errorf("\nSubscribed on invalid Utils.Topic\n")222 }223 // Alphabet-Numeric, forward slash and space test224 testingTopic = "Utils.Topic/13/4jtjos/ "225 if 2 != (subscriber.SubscribeForTopic(testingTopic)) {226 t.Errorf("\nSubscribed on invalid Utils.Topic\n")227 }228 // Special character test229 testingTopic = "*123a"230 if 2 != (subscriber.SubscribeForTopic(testingTopic)) {231 t.Errorf("\nSubscribed on invalid Utils.Topic\n")232 }233 // Sentence test234 testingTopic = "This is a Utils.Topic"235 if 2 != (subscriber.SubscribeForTopic(testingTopic)) {236 t.Errorf("\nSubscribed on invalid Utils.Topic\n")237 }238 // Topic contain forward slash at last239 testingTopic = "Utils.Topic/122/livingroom/"240 if 0 != (subscriber.SubscribeForTopic(testingTopic)) {241 t.Errorf("\nSubscription failed for valid Utils.Topic\n")242 }243 // Topic contain -244 testingTopic = "Utils.Topic/122/livingroom/-"245 if 0 != (subscriber.SubscribeForTopic(testingTopic)) {246 t.Errorf("\nSubscription failed for valid Utils.Topic\n")247 }248 // Topic contain _249 testingTopic = "Utils.Topic/122/livingroom_"250 if 0 != (subscriber.SubscribeForTopic(testingTopic)) {251 t.Errorf("\nSubscription failed for valid Utils.Topic\n")252 }253 // Topic contain .254 testingTopic = "Utils.Topic/122.livingroom."255 if 0 != (subscriber.SubscribeForTopic(testingTopic)) {256 t.Errorf("\nSubscription failed for valid Utils.Topic\n")257 }258 subResult = subscriber.Stop()259 if subResult != 0 {260 t.Errorf("\nError while Stopping subscriber")261 }262}263func TestSubscribeSecured(t *testing.T) {264 subscriber = ezmq.GetEZMQSubscriber(utils.Ip, utils.Port, subCB, subTopicCB)265 if nil == subscriber {266 t.Errorf("\nSubscriber instance is NULL")267 }268 clientPrivateKey := ""269 clientPublicKey := ""270 subResult = subscriber.SetClientKeys([]byte(clientPrivateKey), []byte(clientPublicKey))271 if subResult != ezmq.EZMQ_OK {272 t.Errorf("\nError while setting client keys\n")273 }274 serverPublicKey := ""275 subResult = subscriber.SetServerPublicKey([]byte(serverPublicKey))276 if subResult != ezmq.EZMQ_OK {277 t.Errorf("\nError while setting server key\n")278 }279 //Negative case280 subResult = subscriber.SetClientKeys([]byte(""), []byte(""))281 if subResult != ezmq.EZMQ_ERROR {282 t.Errorf("\nError while setting client keys\n")283 }284 subResult = subscriber.SetServerPublicKey([]byte(""))285 if subResult != ezmq.EZMQ_ERROR {286 t.Errorf("\nError while setting server key\n")287 }288 subResult = subscriber.Start()289 if subResult != 0 {290 t.Errorf("\nError while starting subscriber\n")291 }292 subResult = subscriber.Subscribe()293 if subResult != 0 {294 t.Errorf("\nError while subscribing\n")295 }296 subResult = subscriber.Stop()297 if subResult != 0 {298 t.Errorf("\nError while Stopping subscriber")299 }300}301func TestSubscribeNegative(t *testing.T) {302 subscriber = ezmq.GetEZMQSubscriber(utils.Ip, -1, subCB, subTopicCB)303 if nil == subscriber {304 t.Errorf("\nSubscriber instance is NULL")305 }306 subResult = subscriber.Start()307 if subResult == 0 {308 t.Errorf("\nStarted subscriber on invalid utils.Port\n")309 }310 subResult = subscriber.Subscribe()311 if subResult != 0 {312 t.Errorf("\nSubscribed on invalid subscriber\n")313 }314 subResult = subscriber.Stop()315 if subResult != 0 {316 t.Errorf("\nError while Stopping subscriber")317 }318}319func TestUnSubscribe(t *testing.T) {320 subscriber = ezmq.GetEZMQSubscriber(utils.Ip, utils.Port, subCB, subTopicCB)321 if nil == subscriber {322 t.Errorf("\nSubscriber instance is NULL")323 }324 subResult = subscriber.Start()325 if subResult != 0 {326 t.Errorf("\nError while starting subscriber\n")327 }328 subResult = subscriber.Subscribe()329 if subResult != 0 {330 t.Errorf("\nError while subscribing\n")331 }332 subResult = subscriber.UnSubscribe()333 if subResult != 0 {334 t.Errorf("\nError while unsubscribing\n")335 }336 subResult = subscriber.SubscribeForTopic(utils.Topic)337 if subResult != 0 {338 t.Errorf("\nError while subscribing for Utils.Topic\n")339 }340 subResult = subscriber.UnSubscribeForTopic(utils.Topic)341 if subResult != 0 {342 t.Errorf("\nError while unsubscribing for Utils.Topic\n")343 }344 topicList := List.New()345 e1 := topicList.PushFront("topic1")346 _ = e1347 e2 := topicList.PushFront("topic2")348 _ = e2349 subResult = subscriber.SubscribeForTopicList(*topicList)350 if subResult != 0 {351 t.Errorf("\nError while subscribing for Utils.Topic list\n")352 }353 subResult = subscriber.UnSubscribeForTopicList(*topicList)354 if subResult != 0 {355 t.Errorf("\nError while unsubscribing for Utils.Topic list\n")356 }357 subResult = subscriber.Stop()358 if subResult != 0 {359 t.Errorf("\nError while Stopping subscriber")360 }361}362func TestUnSubscribeNegative(t *testing.T) {363 subscriber = ezmq.GetEZMQSubscriber(utils.Ip, utils.Port, subCB, subTopicCB)364 if nil == subscriber {365 t.Errorf("\nSubscriber instance is NULL")366 }367 subResult = subscriber.Start()368 if subResult != 0 {369 t.Errorf("\nError while starting subscriber\n")370 }371 subResult = subscriber.SubscribeForTopic("")372 if subResult == 0 {373 t.Errorf("\nSubscribed for invalid Utils.Topic\n")374 }375 subResult = subscriber.UnSubscribeForTopic("")376 if subResult == 0 {377 t.Errorf("\nUnSubscribed for invalid Utils.Topic\n")378 }379 topicList := List.New()380 e1 := topicList.PushFront("topic1")381 _ = e1382 e2 := topicList.PushFront("!$topic2")383 _ = e2384 subResult = subscriber.SubscribeForTopicList(*topicList)385 if subResult == 0 {386 t.Errorf("\nSubscribed for invalid Utils.Topic list\n")387 }388 subResult = subscriber.UnSubscribeForTopicList(*topicList)389 if subResult == 0 {390 t.Errorf("\nUnSubscribed for invalid Utils.Topic list\n")391 }392 subResult = subscriber.Stop()393 if subResult != 0 {394 t.Errorf("\nError while Stopping subscriber")395 }396}397func TestSubscriberIPPort(t *testing.T) {398 subscriber = ezmq.GetEZMQSubscriber(utils.Ip, utils.Port, subCB, subTopicCB)399 if nil == subscriber {400 t.Errorf("\nSubscriber instance is NULL")401 }402 subResult = subscriber.Start()403 if subResult != 0 {404 t.Errorf("\nError while starting subscriber\n")405 }406 subResult = subscriber.SubscribeWithIPPort("192.168.1.1", 5562, utils.Topic)407 if subResult != 0 {408 t.Errorf("\nError while subscribing\n")409 }410 subResult = subscriber.SubscribeWithIPPort("192.168.1.1", -1, "")411 if subResult != 1 {412 t.Errorf("\nReturned wrong value\n")413 }414 subResult = subscriber.SubscribeWithIPPort("192.168.1.1", 5562, "")415 if subResult != 2 {416 t.Errorf("\nReturned wrong value\n")417 }418}419func TestSubscribeIPPortSecured(t *testing.T) {420 subscriber = ezmq.GetEZMQSubscriber(utils.Ip, utils.Port, subCB, subTopicCB)421 if nil == subscriber {422 t.Errorf("\nSubscriber instance is NULL")423 }424 clientPrivateKey := ""425 clientPublicKey := ""426 subResult = subscriber.SetClientKeys([]byte(clientPrivateKey), []byte(clientPublicKey))427 if subResult != ezmq.EZMQ_OK {428 t.Errorf("\nError while setting client keys\n")429 }430 serverPublicKey := ""431 subResult = subscriber.SetServerPublicKey([]byte(serverPublicKey))432 if subResult != ezmq.EZMQ_OK {433 t.Errorf("\nError while setting server key\n")434 }435 subResult = subscriber.Start()436 if subResult != 0 {437 t.Errorf("\nError while starting subscriber\n")438 }439 subResult = subscriber.SubscribeWithIPPort("192.168.1.1", 5562, utils.Topic)440 if subResult != 0 {441 t.Errorf("\nError while subscribing\n")442 }443 subResult = subscriber.Stop()444 if subResult != 0 {445 t.Errorf("\nError while Stopping subscriber")446 }447}448func TestSubStartStop(t *testing.T) {449 subscriber = ezmq.GetEZMQSubscriber(utils.Ip, utils.Port, subCB, subTopicCB)450 if nil == subscriber {451 t.Errorf("\nSubscriber instance is NULL")452 }453 for i := 0; i < 15; i++ {454 subResult = subscriber.Start()455 if subResult != 0 {456 t.Errorf("\nError while starting subscriber\n")457 }458 subResult = subscriber.Stop()459 if subResult != 0 {460 t.Errorf("\nError while Stopping subscriber")461 }462 }463}464func TestSubGetIp(t *testing.T) {465 subscriber = ezmq.GetEZMQSubscriber(utils.Ip, utils.Port, subCB, subTopicCB)466 if nil == subscriber {467 t.Errorf("\nSubscriber instance is NULL")468 }469 ip := subscriber.GetIP()470 if ip != utils.Ip {471 t.Errorf("\nAssertion failed")472 }473}474func TestSubGetPort(t *testing.T) {475 subscriber = ezmq.GetEZMQSubscriber(utils.Ip, utils.Port, subCB, subTopicCB)476 if nil == subscriber {477 t.Errorf("\nSubscriber instance is NULL")478 }479 port := subscriber.GetPort()480 if port != utils.Port {481 t.Errorf("\nAssertion failed")482 }483}...

Full Screen

Full Screen

ezmq_publisher_test.go

Source:ezmq_publisher_test.go Github

copy

Full Screen

...21 List "container/list"22 "fmt"23 "testing"24)25var pubResult ezmq.EZMQErrorCode26var pubApiInstance *ezmq.EZMQAPI27var publisher *ezmq.EZMQPublisher28func startCB(code ezmq.EZMQErrorCode) { fmt.Printf("startCB") }29func stopCB(code ezmq.EZMQErrorCode) { fmt.Printf("stopCB") }30func errorCB(code ezmq.EZMQErrorCode) { fmt.Printf("errorCB") }31func TestGetPubInstance(t *testing.T) {32 pubApiInstance = ezmq.GetInstance()33 pubApiInstance.Initialize()34 publisher = ezmq.GetEZMQPublisher(utils.Port, startCB, stopCB, errorCB)35 if nil == publisher {36 t.Errorf("\nPublisher instance is NULL")37 }38 pubApiInstance.Terminate()39}40func TestGePubInstanceNegative(t *testing.T) {41 publisher = nil42 publisher = ezmq.GetEZMQPublisher(utils.Port, startCB, stopCB, errorCB)43 if nil != publisher {44 t.Errorf("\nPublisher instance is NUvLL")45 }46}47func TestPublisherStart(t *testing.T) {48 pubApiInstance = ezmq.GetInstance()49 pubApiInstance.Initialize()50 publisher = ezmq.GetEZMQPublisher(utils.Port, startCB, stopCB, errorCB)51 if nil == publisher {52 t.Errorf("\nPublisher instance is NULL")53 }54 pubResult = publisher.Start()55 if pubResult != 0 {56 t.Errorf("\nError while starting publisher\n")57 }58 pubResult = publisher.Stop()59 if pubResult != 0 {60 t.Errorf("\nError while Stopping publisher")61 }62 pubApiInstance.Terminate()63}64func TestPublish1(t *testing.T) {65 pubApiInstance = ezmq.GetInstance()66 pubApiInstance.Initialize()67 publisher = ezmq.GetEZMQPublisher(utils.Port, startCB, stopCB, errorCB)68 if nil == publisher {69 t.Errorf("\nPublisher instance is NULL")70 }71 pubResult = publisher.Start()72 if pubResult != 0 {73 t.Errorf("\nError while starting publisher\n")74 }75 var event ezmq.Event = utils.GetEvent()76 pubResult = publisher.Publish(event)77 if pubResult != 0 {78 t.Errorf("\nError while publishing event\n")79 }80 byteData := utils.GetByteDataEvent()81 pubResult = publisher.Publish(byteData)82 if pubResult != 0 {83 t.Errorf("\nError while publishing event\n")84 }85 pubResult = publisher.Stop()86 if pubResult != 0 {87 t.Errorf("\nError while Stopping publisher")88 }89 pubApiInstance.Terminate()90}91func TestPublish2(t *testing.T) {92 pubApiInstance = ezmq.GetInstance()93 pubApiInstance.Initialize()94 publisher = ezmq.GetEZMQPublisher(utils.Port, startCB, stopCB, errorCB)95 if nil == publisher {96 t.Errorf("\nPublisher instance is NULL")97 }98 pubResult = publisher.Start()99 if pubResult != 0 {100 t.Errorf("\nError while starting publisher\n")101 }102 var event ezmq.Event = utils.GetEvent()103 pubResult = publisher.PublishOnTopic(utils.Topic, event)104 if pubResult != 0 {105 t.Errorf("\nError while publishing event on utils.Topic\n")106 }107 byteData := utils.GetByteDataEvent()108 pubResult = publisher.PublishOnTopic(utils.Topic, byteData)109 if pubResult != 0 {110 t.Errorf("\nError while publishing byte data on utils.Topic\n")111 }112 pubResult = publisher.Stop()113 if pubResult != 0 {114 t.Errorf("\nError while Stopping publisher")115 }116 pubApiInstance.Terminate()117}118func TestPublish3(t *testing.T) {119 pubApiInstance = ezmq.GetInstance()120 pubApiInstance.Initialize()121 publisher = ezmq.GetEZMQPublisher(utils.Port, startCB, stopCB, errorCB)122 if nil == publisher {123 t.Errorf("\nPublisher instance is NULL")124 }125 pubResult = publisher.Start()126 if pubResult != 0 {127 t.Errorf("\nError while starting publisher\n")128 }129 var event ezmq.Event = utils.GetEvent()130 topicList := List.New()131 pubResult = publisher.PublishOnTopicList(*topicList, event)132 if pubResult != 2 {133 t.Errorf("\nWrong error code\n")134 }135 e1 := topicList.PushFront("topic1")136 _ = e1137 e2 := topicList.PushFront("topic2")138 _ = e2139 pubResult = publisher.PublishOnTopicList(*topicList, event)140 if pubResult != 0 {141 t.Errorf("\nError while publishing event on utils.Topic list\n")142 }143 byteData := utils.GetByteDataEvent()144 pubResult = publisher.PublishOnTopicList(*topicList, byteData)145 if pubResult != 0 {146 t.Errorf("\nError while publishing byte data on utils.Topic list\n")147 }148 e3 := topicList.PushFront("")149 _ = e3150 pubResult = publisher.PublishOnTopicList(*topicList, event)151 if pubResult == 0 {152 t.Errorf("\nPublished on wrong utils.Topic list\n")153 }154 pubResult = publisher.PublishOnTopicList(*topicList, byteData)155 if pubResult == 0 {156 t.Errorf("\nError while publishing byte data on utils.Topic list\n")157 }158 pubResult = publisher.Stop()159 if pubResult != 0 {160 t.Errorf("Error while Stopping publisher")161 }162 pubApiInstance.Terminate()163}164func TestPublishSecured(t *testing.T) {165 pubApiInstance = ezmq.GetInstance()166 pubApiInstance.Initialize()167 publisher = ezmq.GetEZMQPublisher(utils.Port, startCB, stopCB, errorCB)168 if nil == publisher {169 t.Errorf("\nPublisher instance is NULL")170 }171 // put server key172 serverSecretKey := ""173 pubResult = publisher.SetServerPrivateKey([]byte(serverSecretKey))174 if pubResult != ezmq.EZMQ_OK {175 t.Errorf("\nError while setting server private key\n")176 }177 //negative case178 pubResult = publisher.SetServerPrivateKey([]byte(""))179 if pubResult != ezmq.EZMQ_ERROR {180 t.Errorf("\nWrong error code\n")181 }182 pubResult = publisher.Start()183 if pubResult != 0 {184 t.Errorf("\nError while starting publisher\n")185 }186 var event ezmq.Event = utils.GetEvent()187 pubResult = publisher.Publish(event)188 if pubResult != 0 {189 t.Errorf("\nError while publishing event\n")190 }191 byteData := utils.GetByteDataEvent()192 pubResult = publisher.Publish(byteData)193 if pubResult != 0 {194 t.Errorf("\nError while publishing event\n")195 }196 pubResult = publisher.Stop()197 if pubResult != 0 {198 t.Errorf("\nError while Stopping publisher")199 }200 pubApiInstance.Terminate()201}202func TestPublicTopic(t *testing.T) {203 pubApiInstance = ezmq.GetInstance()204 pubApiInstance.Initialize()205 publisher = ezmq.GetEZMQPublisher(utils.Port, startCB, stopCB, errorCB)206 if nil == publisher {207 t.Errorf("\nPublisher instance is NULL")208 }209 pubResult = publisher.Start()210 if pubResult != 0 {211 t.Errorf("\nError while starting publisher\n")212 }213 var event ezmq.Event = utils.GetEvent()214 byteData := utils.GetByteDataEvent()215 var testingTopic string = ""216 // Empty utils.Topic test217 if 2 != (publisher.PublishOnTopic(testingTopic, event)) {218 t.Errorf("\nPublished on invalid utils.Topic\n")219 }220 if 2 != (publisher.PublishOnTopic(testingTopic, byteData)) {221 t.Errorf("\nPublished on invalid utils.Topic\n")222 }223 // Alphabet test224 testingTopic = "utils.Topic"225 if 0 != (publisher.PublishOnTopic(testingTopic, event)) {226 t.Errorf("\nPublished failed for valid utils.Topic\n")227 }228 if 0 != (publisher.PublishOnTopic(testingTopic, byteData)) {229 t.Errorf("\nPublished failed for valid utils.Topic\n")230 }231 // Numeric test232 testingTopic = "123"233 if 0 != (publisher.PublishOnTopic(testingTopic, event)) {234 t.Errorf("\nPublished failed for valid utils.Topic\n")235 }236 if 0 != (publisher.PublishOnTopic(testingTopic, byteData)) {237 t.Errorf("\nPublished failed for valid utils.Topic\n")238 }239 // Alpha-Numeric test240 testingTopic = "1a2b3"241 if 0 != (publisher.PublishOnTopic(testingTopic, event)) {242 t.Errorf("\nPublished failed for valid utils.Topic\n")243 }244 if 0 != (publisher.PublishOnTopic(testingTopic, byteData)) {245 t.Errorf("\nPublished failed for valid utils.Topic\n")246 }247 // Alphabet forward slash test248 testingTopic = "utils.Topic/"249 if 0 != (publisher.PublishOnTopic(testingTopic, event)) {250 t.Errorf("\nPublished failed for valid utils.Topic\n")251 }252 if 0 != (publisher.PublishOnTopic(testingTopic, byteData)) {253 t.Errorf("\nPublished failed for valid utils.Topic\n")254 }255 // Alphabet-Numeric, forward slash test256 testingTopic = "utils.Topic/13/4jtjos/"257 if 0 != (publisher.PublishOnTopic(testingTopic, event)) {258 t.Errorf("\nPublished failed for valid utils.Topic\n")259 }260 if 0 != (publisher.PublishOnTopic(testingTopic, byteData)) {261 t.Errorf("\nPublished failed for valid utils.Topic\n")262 }263 // Alphabet-Numeric, forward slash test264 testingTopic = "123a/1this3/4jtjos"265 if 0 != (publisher.PublishOnTopic(testingTopic, event)) {266 t.Errorf("\nPublished failed for valid utils.Topic\n")267 }268 if 0 != (publisher.PublishOnTopic(testingTopic, byteData)) {269 t.Errorf("\nPublished failed for valid utils.Topic\n")270 }271 // Alphabet, backslash test272 testingTopic = "utils.Topic\";"273 if 2 != (publisher.PublishOnTopic(testingTopic, event)) {274 t.Errorf("\nPublished on invalid utils.Topic\n")275 }276 if 2 != (publisher.PublishOnTopic(testingTopic, byteData)) {277 t.Errorf("\nPublished on invalid utils.Topic\n")278 }279 // Alphabet-Numeric, forward slash and space test280 testingTopic = "utils.Topic/13/4jtjos/ "281 if 2 != (publisher.PublishOnTopic(testingTopic, event)) {282 t.Errorf("\nPublished on invalid utils.Topic\n")283 }284 if 2 != (publisher.PublishOnTopic(testingTopic, byteData)) {285 t.Errorf("\nPublished on invalid utils.Topic\n")286 }287 // Special character test288 testingTopic = "*123a"289 if 2 != (publisher.PublishOnTopic(testingTopic, event)) {290 t.Errorf("\nPublished on invalid utils.Topic\n")291 }292 if 2 != (publisher.PublishOnTopic(testingTopic, byteData)) {293 t.Errorf("\nPublished on invalid utils.Topic\n")294 }295 // Sentence test296 testingTopic = "This is a utils.Topic"297 if 2 != (publisher.PublishOnTopic(testingTopic, event)) {298 t.Errorf("\nPublished on invalid utils.Topic\n")299 }300 if 2 != (publisher.PublishOnTopic(testingTopic, byteData)) {301 t.Errorf("\nPublished on invalid utils.Topic\n")302 }303 // Topic contain forward slash at last304 testingTopic = "utils.Topic/122/livingroom/"305 if 0 != (publisher.PublishOnTopic(testingTopic, event)) {306 t.Errorf("\nPublished failed for valid utils.Topic\n")307 }308 if 0 != (publisher.PublishOnTopic(testingTopic, byteData)) {309 t.Errorf("\nPublished failed for valid utils.Topic\n")310 }311 // Topic contain -312 testingTopic = "utils.Topic/122/livingroom/-"313 if 0 != (publisher.PublishOnTopic(testingTopic, event)) {314 t.Errorf("\nPublished failed for valid utils.Topic\n")315 }316 if 0 != (publisher.PublishOnTopic(testingTopic, byteData)) {317 t.Errorf("\nPublished failed for valid utils.Topic\n")318 }319 // Topic contain _320 testingTopic = "utils.Topic/122/livingroom_"321 if 0 != (publisher.PublishOnTopic(testingTopic, event)) {322 t.Errorf("\nPublished failed for valid utils.Topic\n")323 }324 if 0 != (publisher.PublishOnTopic(testingTopic, byteData)) {325 t.Errorf("\nPublished failed for valid utils.Topic\n")326 }327 // Topic contain .328 testingTopic = "utils.Topic/122.livingroom."329 if 0 != (publisher.PublishOnTopic(testingTopic, event)) {330 t.Errorf("\nPublished failed for valid utils.Topic\n")331 }332 if 0 != (publisher.PublishOnTopic(testingTopic, byteData)) {333 t.Errorf("\nPublished failed for valid utils.Topic\n")334 }335 pubResult = publisher.Stop()336 if pubResult != 0 {337 t.Errorf("\nError while Stopping publisher")338 }339 pubApiInstance.Terminate()340}341func TestPublishNegative(t *testing.T) {342 pubApiInstance = ezmq.GetInstance()343 pubApiInstance.Initialize()344 publisher = ezmq.GetEZMQPublisher(utils.Port, startCB, stopCB, errorCB)345 if nil == publisher {346 t.Errorf("\nPublisher instance is NULL")347 }348 pubResult = publisher.Start()349 if pubResult != 0 {350 t.Errorf("\nError while starting publisher\n")351 }352 var event ezmq.Event = utils.GetWrongEvent()353 pubResult = publisher.Publish(event)354 if pubResult == 0 {355 t.Errorf("\nPublished wrong event\n")356 }357 pubResult = publisher.Publish(nil)358 if pubResult == 0 {359 t.Errorf("\nPublished nil event\n")360 }361 pubResult = publisher.PublishOnTopic(utils.Topic, event)362 if pubResult == 0 {363 t.Errorf("\nPublished wrong event\n")364 }365 pubResult = publisher.PublishOnTopic(utils.Topic, nil)366 if pubResult == 0 {367 t.Errorf("\nPublished wrong event\n")368 }369 topicList := List.New()370 e1 := topicList.PushFront("topic1")371 _ = e1372 e2 := topicList.PushFront("")373 _ = e2374 pubResult = publisher.PublishOnTopicList(*topicList, event)375 if pubResult == 0 {376 t.Errorf("\nPublished invalid topiclist\n")377 }378 byteData := utils.GetByteDataEvent()379 pubResult = publisher.PublishOnTopicList(*topicList, byteData)380 if pubResult == 0 {381 t.Errorf("\nPublished invalid topiclist\n")382 }383 pubResult = publisher.Stop()384 if pubResult != 0 {385 t.Errorf("\nError while Stopping publisher")386 }387 pubApiInstance.Terminate()388}389func TestPubStartStop(t *testing.T) {390 pubApiInstance = ezmq.GetInstance()391 pubApiInstance.Initialize()392 publisher = ezmq.GetEZMQPublisher(utils.Port, startCB, stopCB, errorCB)393 if nil == publisher {394 t.Errorf("\nPublisher instance is NULL")395 }396 for i := 0; i < 15; i++ {397 pubResult = publisher.Start()398 if pubResult != 0 {399 t.Errorf("\nError while starting publisher\n")400 }401 pubResult = publisher.Stop()402 if pubResult != 0 {403 t.Errorf("\nError while stopping publisher\n")404 }405 }406 pubApiInstance.Terminate()407}408func TestPubGetPort(t *testing.T) {409 pubApiInstance = ezmq.GetInstance()410 pubApiInstance.Initialize()411 publisher = ezmq.GetEZMQPublisher(utils.Port, startCB, stopCB, errorCB)412 if nil == publisher {413 t.Errorf("\nPublisher instance is NULL")414 }415 port := publisher.GetPort()416 if port != utils.Port {417 t.Errorf("\nAssertion failed")418 }419}...

Full Screen

Full Screen

core.go

Source:core.go Github

copy

Full Screen

...44 ssdbClients []*ssdb.SSDBClient, reqChannel *amqp.Channel,45 respChannel *amqp.Channel, crawlerName string, respQueueName string) error {46 resp, err := local_http.Send(proxyClient, req, httpClient)47 if err != nil {48 utils.Info.Println("http Send fail", crawlerName, err.Error(), resp.HttpProxy)49 // Remove http_proxy in redis to improve proxy quality.50 if resp.HttpProxy != "" {51 p := pureProxy(resp.HttpProxy)52 utils.Info.Println("delete proxy ", p)53 err = proxy.Delete(proxyClient, p, req.ProxyName)54 if err != nil {55 utils.Error.Println("delete proxy fail", err.Error())56 }57 }58 return request.Done(reqChannel, req, false)59 }60 err = response.Push(ssdbClients, resp)61 if err != nil {62 utils.Error.Println("response Push fail", crawlerName, err.Error())63 return request.Done(reqChannel, req, false)64 }65 err = response.PushKey(respChannel, resp, respQueueName)66 if err != nil {67 utils.Error.Println("response PushKey fail", crawlerName, err.Error())68 return request.Done(reqChannel, req, false)69 }70 return request.Done(reqChannel, req, true)71}72func consumer(73 c *core_consumer.CoreConsumer,74 connPool *rabbitmq.ConnPool,75 ssdbClients []*ssdb.SSDBClient,76 httpClient *http.Client,77 proxyClient *ssdb.ProxyClient) {78 defer core_consumer.ExitCoreConsumer(c)79 utils.Info.Printf("[%s] start consumer", c.CrawlerName)80 conn := connPool.Get().(*amqp.Connection)81 connPool.Release(conn)82 reqChannel, err := conn.Channel()83 if err != nil {84 utils.Error.Println("request MakeChannel fail and exit ", c.CrawlerName, err.Error())85 return86 } else {87 utils.Info.Println(c.CrawlerName, "request MakeChannel ok")88 }89 defer reqChannel.Close()90 err = reqChannel.Qos(30, 0, false)91 if err != nil {92 utils.Error.Println("request channel Qos fail and exit", c.CrawlerName, err.Error())93 return94 }95 respChannel, err := conn.Channel()96 respChannel.Confirm(false)97 if err != nil {98 utils.Error.Println("response MakeChannel fail and exit ", c.CrawlerName, err.Error())99 return100 } else {101 utils.Info.Println(c.CrawlerName, "response MakeChannel ok")102 }103 defer respChannel.Close()104 deliveries, err := request.Consume(reqChannel, c.ReqQueue)105 if err != nil {106 utils.Error.Println("request Consume fail: ", c)107 return108 }109 ticker := time.NewTicker(5 * time.Second)110 for {111 select {112 case <-ticker.C:113 utils.Debug.Println("check channel status", c.CrawlerName, c.ReqQueue, c.RespQueue)114 q, err := reqChannel.QueueInspect(c.ReqQueue)115 if err != nil {116 utils.Info.Println(c.CrawlerName, "QueueInspect fail", err.Error())117 return118 } else if err == nil && q.Messages == 0 {119 utils.Info.Println("QueueInspect empty and exit")120 return121 } else {122 utils.Debug.Println("QueueInspect success", c)123 }124 q, err = respChannel.QueueInspect(c.RespQueue)125 if err != nil {126 utils.Info.Println(c.CrawlerName, "RespQueue QueueInspect fail", err.Error())127 return128 } else {129 utils.Debug.Println("QueueInspect success", c)130 }131 case d := <-deliveries:132 req, err := request.Get(d)133 if err == nil && req == nil {134 utils.Info.Printf("[%s]consumer Get Delivery empty\n", c.CrawlerName)135 _, err = reqChannel.QueueInspect(c.ReqQueue)136 if err != nil {137 utils.Info.Println(c.CrawlerName, "QueueInspect fail", err.Error())138 return139 } else {140 time.Sleep(1 * time.Second)141 }142 continue143 }144 if err != nil {145 utils.Info.Printf("[%s]request Get deliveries error: %s\n", c.CrawlerName, string(d.Body))146 } else {147 utils.Debug.Println("consume ", req.Url)148 go consume(httpClient, proxyClient, req, ssdbClients, reqChannel, respChannel, c.CrawlerName, c.RespQueue)149 }150 default:151 utils.Debug.Println("coming to default operation", c)152 time.Sleep(10 * time.Millisecond)153 }154 }155}156func cleanup(cfg config.Config, proxyClient *ssdb.ProxyClient) {157 proxyClient.ConnPool.Close()158 utils.Info.Printf("process exit")159}160func run(cfgFile string, consumerNumber int, crawlerName string) {161 var conn *amqp.Connection162 var consumers []*core_consumer.CoreConsumer163 cfg, err := config.Get(cfgFile)164 if err != nil {165 utils.Error.Println("read config file fail ", err.Error(), cfgFile)166 return167 }168 proxyNode := config.SSDBNode{169 Host: cfg.ProxyRedisIp,170 Port: cfg.ProxyRedisPort,171 }172 ssdbNodes := cfg.SSDBNodes173 if len(ssdbNodes) == 0 {174 utils.Error.Println("ssdb nodes can not be empty")175 return176 }177 ssdbClients := ssdb.GetClients(ssdbNodes, cfg, ssdb.Params{MaxIdle: 5000, MaxActive: 5000})178 proxyClient := ssdb.GetProxyClient(proxyNode, ssdb.Params{MaxIdle: 5000, MaxActive: 5000})179 connPool := &rabbitmq.ConnPool{180 MaxIdle: 10,181 MaxActive: 50,182 Dial: rabbitmq.CreateConn,183 Cfg: cfg,184 }185 maxConn := 1000186 httpClients := CrawlerHttpClients(consumerNumber, maxConn)187 sigs := make(chan os.Signal, 1)188 signal.Notify(sigs, os.Interrupt)189 signal.Notify(sigs, syscall.SIGTERM)190 go func() {191 <-sigs192 cleanup(cfg, proxyClient)193 os.Exit(0)194 }()195 for {196 reqQueues, err := core_queue.GetQueues("http_request:", cfg)197 if err != nil {198 utils.Error.Printf("GetReqQueues error:%s\n", err.Error())199 time.Sleep(1 * time.Second)200 continue201 } else {202 utils.Debug.Println("GetReqQueues success")203 }204 respQueues, err := core_queue.GetQueues("http_response:", cfg)205 if err != nil {206 utils.Error.Printf("GetRespQueues error:%s\n", err.Error())207 time.Sleep(1 * time.Second)208 continue209 } else {210 utils.Debug.Println("GetRespQueues success")211 }212 conn = connPool.Get().(*amqp.Connection)213 reqQueues, err = core_queue.UpdateQueueCount(reqQueues, conn)214 if err != nil {215 utils.Error.Println(err.Error())216 time.Sleep(1 * time.Second)217 continue218 } else {219 utils.Debug.Println("UpdateQueueCount success")220 }221 connPool.Release(conn)222 reqQueues = core_queue.RemoveEmptyQueues(reqQueues)223 utils.Debug.Println(reqQueues)224 if len(reqQueues) == 0 {225 utils.Info.Println("req queues empty")226 time.Sleep(1 * time.Second)227 continue228 } else {229 utils.Debug.Println("RemoveEmptyQueues success")230 }231 core_queue.DeclareResponseQueues(conn, reqQueues, 5)232 conn = connPool.Get().(*amqp.Connection)233 respQueues, err = core_queue.UpdateQueueCount(respQueues, conn)234 utils.Debug.Println(respQueues)235 if err != nil {236 conn = nil237 utils.Error.Println(err.Error())238 time.Sleep(1 * time.Second)239 continue240 }241 connPool.Release(conn)242 if len(respQueues) == 0 {243 utils.Info.Println("resp queues empty")244 time.Sleep(1 * time.Second)245 continue246 }247 consumers = core_consumer.AliveCrawlerConsumers(consumers, crawlerName)248 utils.Debug.Println("total consumers: ", len(consumers), ", need start consumers:", consumerNumber-len(consumers))249 newConsumers := consumerNumber - len(consumers)250 for i := 0; i < newConsumers; i++ {251 reqQueueName, err := core_queue.GetRandReqQueue(reqQueues, crawlerName)252 if err != nil {253 utils.Error.Printf(err.Error())254 continue255 }256 utils.Debug.Printf("GetRandReqQueue %s\n", reqQueueName)257 respQueueName, err := core_queue.GetRandRespQueue(respQueues, crawlerName)258 if err != nil {259 utils.Error.Printf(err.Error())260 continue261 }262 utils.Debug.Printf("GetRandRespQueue %s\n", respQueueName)263 index := i / maxConn264 c := core_consumer.CreateCoreConsumer(i, crawlerName, reqQueueName, respQueueName)265 consumers = append(consumers, c)266 utils.Debug.Println("add consumer", c)267 go consumer(c, connPool, ssdbClients, httpClients[index], proxyClient)268 }269 if len(consumers) < consumerNumber {270 utils.Warning.Printf("aliveConsumers now %d, lower than %d\n", len(consumers), consumerNumber)271 }272 utils.Debug.Println("total consumers ", len(consumers))273 time.Sleep(1 * time.Second)274 }275}276func main() {277 logLevel := flag.String("level", "info", "log level: debug, info, warning, error")278 // logFile := flag.String("log_file", "/var/log/yascrapy/core.log", "specify the output log file")279 cfgFile := flag.String("config_file", "/etc/yascrapy/core.json", "specify core downloader config file in json")280 consumers := flag.Int("consumers", 1, "specify consumers number")281 crawlerName := flag.String("crawler_name", "", "specify crawler name, can not be empty")282 flag.Parse()283 // handles, err := utils.GetHandles(*logLevel, *logFile)284 handles, err := utils.GetHandles(*logLevel)285 if err != nil {286 fmt.Println(err.Error())287 return288 }289 if *crawlerName == "" {290 fmt.Println("crawlerName can not be empty")291 return292 }293 utils.InitLoggers(handles[0], handles[1], handles[2], handles[3])294 rand.Seed(time.Now().Unix())295 run(*cfgFile, *consumers, *crawlerName)296}...

Full Screen

Full Screen

Error

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 err := utils.New("This is a new error")4 if err != nil {5 fmt.Println(err.Error())6 }7}

Full Screen

Full Screen

Error

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println(utils.Error("Error occured"))4}5import (6func main() {7 fmt.Println(utils.Error("Error occured"))8}9import (10func main() {11 fmt.Println(utils.Error("Error occured"))12}13import (14func main() {15 fmt.Println(utils.Error("Error occured"))16}17import (18func main() {19 fmt.Println(utils.Error("Error occured"))20}21import (22func main() {23 fmt.Println(utils.Error("Error occured"))24}25import (26func main() {27 fmt.Println(utils.Error("Error occured"))28}29import (30func main() {31 fmt.Println(utils.Error("Error occured"))32}33import (34func main() {35 fmt.Println(utils.Error("Error occured"))36}37import (

Full Screen

Full Screen

Error

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println("Error method of utils class")4 utils.Error("Error message")5}6import (7func Error(message string) {8 log.Printf("Error: %s", message)9}10import (11func TestError(t *testing.T) {12 Error("Test Error")13}14import (15func main() {16 fmt.Println("Fatal method of utils class")17 utils.Fatal("Fatal message")18}19import (20func Fatal(message string) {21 log.Fatalf("Fatal: %s", message)22}23import (24func TestFatal(t *testing.T) {25 Fatal("Test Fatal")26}27| log.Print() | Logs the message to the console |28| log.Println() | Logs the message to the console and adds a new line |29| log.Printf() | Logs the message to the console using the format specifier |30| log.Fatal() | Logs the message to the console and exits the program |31| log.Fatalf() | Logs the message to the console using the format specifier and exits the program |32| log.Panic() | Logs the message to the console and panics |33| log.Panicf() | Logs the message to the console using the format specifier and panics |34| log.New() | Creates a logger object |35| logger.SetOutput() | Sets the file to which the messages are logged |36| logger.Print() | Logs the message to the console |37| logger.Println() | Logs the message to the console and adds a new line |38| logger.Printf() | Logs the message to the console using the format specifier |

Full Screen

Full Screen

Error

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 utils.Error("Error")4}5import (6func Error(msg string) {7 fmt.Println(msg)8}9import (10func TestError(t *testing.T) {11 Error("Error")12}13import (14func TestError(t *testing.T) {15 Error("Error")16}17import (18func main() {19 utils.Error("Error")20}21import (22func Error(msg string) {23 fmt.Println(msg)24}25import (26func TestError(t *testing.T) {27 Error("Error")28}29import (30func main() {31 utils.Error("Error")32}33import (34func Error(msg string) {35 fmt.Println(msg)36}37import (38func TestError(t *testing.T) {39 Error("Error")40}41import (42func main() {43 utils.Error("Error")44}45import (46func Error(msg string) {47 fmt.Println(msg)48}49import (50func TestError(t *testing.T) {51 Error("Error")52}53import (54func main() {55 utils.Error("Error")56}57import (

Full Screen

Full Screen

Error

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println("Hello, playground")4 fmt.Println(utils.Error("2.go", "Error"))5}6import (7func main() {8 fmt.Println("Hello, playground")9 fmt.Println(utils.Error("3.go", "Error"))10}11import (12func main() {13 fmt.Println("Hello, playground")14 fmt.Println(utils.Error("4.go", "Error"))15}16import (17func main() {18 fmt.Println("Hello, playground")19 fmt.Println(utils.Error("5.go", "Error"))20}21import (22func main() {23 fmt.Println("Hello, playground")24 fmt.Println(utils.Error("6.go", "Error"))25}26import (27func main() {28 fmt.Println("Hello, playground")29 fmt.Println(utils.Error("7.go", "Error"))30}31import (32func main() {33 fmt.Println("Hello, playground")34 fmt.Println(utils.Error("8.go", "Error"))35}36import (37func main() {38 fmt.Println("Hello, playground")39 fmt.Println(utils.Error("9.go", "Error"))40}41import (42func main() {43 fmt.Println("Hello, playground")44 fmt.Println(utils.Error("10.go", "Error"))45}46import (47func main() {48 fmt.Println("Hello

Full Screen

Full Screen

Error

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println("Go Error Demo")4 err := utils.Error("error message")5 fmt.Println(err)6}7import "fmt"8func Error(msg string) error {9 return fmt.Errorf("Error: %s", msg)10}

Full Screen

Full Screen

Error

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 result := utils.Error("Error")4 fmt.Println(result)5}6func Error(msg string) string {7}8import (9func main() {10 result := utils.Error("Error")11 fmt.Println(result)12}13import (14func main() {15 result := utils.Error("Error")16 fmt.Println(result)17}18func Error(msg string) string {19}20import (21func main() {22 result := utils.Error("Error")23 fmt.Println(result)24}

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful