Skip to content

Commit

Permalink
Adjust tests
Browse files Browse the repository at this point in the history
Signed-off-by: Tomek Urbaszek <[email protected]>
  • Loading branch information
turbaszek committed Sep 10, 2020
1 parent d779177 commit 12a6cb6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pkg/scalers/rabbitmq_scaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ type rabbitMQScaler struct {

type rabbitMQMetadata struct {
queueName string
host string // connection string for either HTTP or AMQP protocol
queueLength int
host string // connection string for either HTTP or AMQP protocol
protocol string // either http or amqp protocol
}

Expand Down
16 changes: 7 additions & 9 deletions pkg/scalers/rabbitmq_scaler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import (
)

const (
host = "myHostSecret"
apiHost = "myApiHostSecret"
host = "myHostSecret"
)

type parseRabbitMQMetadataTestData struct {
Expand All @@ -26,8 +25,7 @@ type rabbitMQMetricIdentifier struct {
}

var sampleRabbitMqResolvedEnv = map[string]string{
host: "amqp://user:[email protected]:5236/vhost",
apiHost: "https://user:[email protected]/vhost",
host: "amqp://user:[email protected]:5236/vhost",
}

var testRabbitMQMetadata = []parseRabbitMQMetadataTestData{
Expand All @@ -43,8 +41,8 @@ var testRabbitMQMetadata = []parseRabbitMQMetadataTestData{
{map[string]string{"queueLength": "10", "hostFromEnv": host}, true, map[string]string{}},
// host defined in authParams
{map[string]string{"queueLength": "10"}, true, map[string]string{"host": host}},
// properly formed metadata with includeUnacked
{map[string]string{"queueLength": "10", "queueName": "sample", "apiHostFromEnv": apiHost, "includeUnacked": "true"}, false, map[string]string{}},
// properly formed metadata with http protocol
{map[string]string{"queueLength": "10", "queueName": "sample", "host": host, "protocol": "http"}, false, map[string]string{}},
}

var rabbitMQMetricIdentifiers = []rabbitMQMetricIdentifier{
Expand All @@ -67,7 +65,7 @@ var testDefaultQueueLength = []parseRabbitMQMetadataTestData{
// use default queueLength
{map[string]string{"queueName": "sample", "host": host}, false, map[string]string{}},
// use default queueLength with includeUnacked
{map[string]string{"queueName": "sample", "apiHost": apiHost, "includeUnacked": "true"}, false, map[string]string{}},
{map[string]string{"queueName": "sample", "host": host, "protocol": "http"}, false, map[string]string{}},
}

func TestParseDefaultQueueLength(t *testing.T) {
Expand Down Expand Up @@ -118,12 +116,12 @@ func TestGetQueueInfo(t *testing.T) {
w.Write([]byte(testData.response))
}))

resolvedEnv := map[string]string{apiHost: fmt.Sprintf("%s%s", apiStub.URL, vhostPath)}
resolvedEnv := map[string]string{host: fmt.Sprintf("%s%s", apiStub.URL, vhostPath)}

metadata := map[string]string{
"queueLength": "10",
"queueName": "evaluate_trials",
"apiHostFromEnv": apiHost,
"hostFromEnv": host,
"includeUnacked": "true",
}

Expand Down

0 comments on commit 12a6cb6

Please sign in to comment.