Exemplo n.º 1
0
func TestDefaultQueueStorage(t *testing.T) {
	var input []http.Request = make([]http.Request, 10)
	var output []http.Request = make([]http.Request, 10)

	queue := queue.New()

	for i := 0; i < 10; i++ {
		req, err := http.NewRequest("GET", "http://localhost/request/"+i, nil)
		if err != nil {
			t.Fatal("Failed to prepare test input")
		}

		if err = queue.Enqueue(req); err != nil {
			t.Fatal("Failed to enqueue request")
		}

		input[i] = req
	}

	for i := 0; i < 10; i++ {
		req, err := queue.Dequeue()
		if err != nil {
			t.Fatal("Failed to dequeue request")
		}

		if req != input[i] {
			t.Fatal("Queue elements are not in the right order")
		}
	}
}
Exemplo n.º 2
0
func init() {
	clientUrl = os.Getenv("QUEUE_PROXY_CLIENT_URL")
	flag.StringVar(&clientUrl, "client-url", "", "Client url enpoint")
	if clientUrl == "" {
		log.Fatal("Missing client endpoint configuration.")
	}

	q = queue.New()
}