-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3106d38
commit f3b0df4
Showing
9 changed files
with
291 additions
and
168 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// Copyright (C) 2017 Jan Delgado | ||
|
||
// +build integration | ||
|
||
package main | ||
|
||
import ( | ||
"crypto/tls" | ||
"os" | ||
"testing" | ||
"time" | ||
|
||
rabtap "github.com/jandelgado/rabtap/pkg" | ||
"github.com/jandelgado/rabtap/pkg/testcommon" | ||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestCmdPurgeQueue(t *testing.T) { | ||
|
||
// create a queue, publish some messages, purge queue and make | ||
// sure queue is empty | ||
oldArgs := os.Args | ||
defer func() { os.Args = oldArgs }() | ||
|
||
const testMessage = "SubHello" | ||
const testQueue = "purge-queue-test" | ||
const testKey = testQueue | ||
const testExchange = "amq.direct" | ||
|
||
amqpURI := testcommon.IntegrationURIFromEnv() | ||
apiURI := testcommon.IntegrationAPIURIFromEnv() | ||
|
||
os.Args = []string{"rabtap", "queue", | ||
"create", testQueue, | ||
"--uri", amqpURI} | ||
main() | ||
|
||
os.Args = []string{"rabtap", "queue", | ||
"bind", testQueue, | ||
"to", testExchange, | ||
"--bindingkey", testQueue, | ||
"--uri", amqpURI} | ||
main() | ||
|
||
// TODO publish messages | ||
|
||
// purge queue and check size | ||
os.Args = []string{"rabtap", "queue", | ||
"purge", testQueue, | ||
"--uri", amqpURI} | ||
main() | ||
|
||
time.Sleep(2 * time.Second) | ||
client := rabtap.NewRabbitHTTPClient(apiURI, &tls.Config{}) | ||
queues, err := client.Queues() | ||
assert.Nil(t, err) | ||
queue := rabtap.FindQueueByName(queues, "/", testQueue) | ||
require.NotNil(t, queue) | ||
|
||
// TODO | ||
assert.Equal(t, 0, queue.Messages) | ||
} |
Oops, something went wrong.