Skip to content

Commit

Permalink
Fixed config to remove dead params. Added tests for reading in config
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisCooney committed Aug 24, 2017
1 parent 2cadaa5 commit 14634fb
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
27 changes: 27 additions & 0 deletions config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,33 @@ import (
"testing"
)

func TestGetConfig(t *testing.T) {
t.Run("Test ability to load in correct config", func(t *testing.T) {
configPath := "examples/config.json"
config := GetConfig(configPath)

if config == nil {
t.Error("Expected Config to be parsed. Got nil")
}

if len(config.Endpoints) == 0 {
t.Error("Expected Config to contain endpoints. Endpoints length = 0")
}

endpoint := config.Endpoints[0]

if endpoint.Name != "QA List orders Endpoint" {
t.Errorf("Incorrect name for first endpoint. Expected QA List Orders Endpoint. Got %s", endpoint.Name)
}

attack := endpoint.Attacks[0]

if attack.Type != "CORRUPT_HTTP" {
t.Errorf("Expected attack to be CORRUPT_HTTP. Got %s", attack.Type)
}
})
}

func TestIsValidConfig(t *testing.T) {
t.Run("Test ability to check for config errors", func(t *testing.T) {
config := &Config{}
Expand Down
4 changes: 0 additions & 4 deletions examples/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"attacks": [
{
"type": "CORRUPT_HTTP",
"maxResponseTime": 5000,
"expectedStatus": "400"
}
]
Expand All @@ -20,12 +19,9 @@
"port": "5000",
"path": "/orders/2",
"protocol": "http",
"maxResponseTime": 5000,
"expectedStatus": "200",
"attacks": [
{
"type": "HTTP_SPAM",
"maxResponseTime": 5000,
"expectedStatus": "200",
"concurrents": 10,
"messagesPerConcurrent": 20,
Expand Down

0 comments on commit 14634fb

Please sign in to comment.