Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[STK-114] Add Test cases #4

Merged
merged 5 commits into from
Feb 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/config_test.go
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
package main

import (
"testing"
"reflect"
"testing"
)

func TestConfigWithCorrectValues(t *testing.T){
func TestConfigWithCorrectValues(t *testing.T) {
correctConfig := Config{Providers: []Provider{Provider{Name: "UptimeRobot", ApiKey: "657a68d9ashdyasjdklkskuasd", ApiURL: "https://api.uptimerobot.com/v2/", AlertContacts: "0544483_0_0-2628365_0_0-2633263_0_0"}}, EnableMonitorDeletion: true}
config := ReadConfig("test-config.yaml")

if ! reflect.DeepEqual(config, correctConfig) {
if !reflect.DeepEqual(config, correctConfig) {
t.Error("Marshalled config and correct config do not match")
}
}

func TestConfigWithIncorrectProviderValues(t *testing.T){
func TestConfigWithIncorrectProviderValues(t *testing.T) {
incorrectConifg := Config{Providers: []Provider{Provider{Name: "UptimeRobot2", ApiKey: "abc", ApiURL: "https://api.uptimerobot.com/v2/", AlertContacts: "0544483_0_0-2628365_0_0-2633263_0_0"}}, EnableMonitorDeletion: true}
config := ReadConfig("test-config.yaml")

Expand All @@ -23,7 +23,7 @@ func TestConfigWithIncorrectProviderValues(t *testing.T){
}
}

func TestConfigWithIncorrectEnableFlag(t *testing.T){
func TestConfigWithIncorrectEnableFlag(t *testing.T) {
incorrectConifg := Config{Providers: []Provider{Provider{Name: "UptimeRobot", ApiKey: "657a68d9ashdyasjdklkskuasd", ApiURL: "https://api.uptimerobot.com/v2/", AlertContacts: "0544483_0_0-2628365_0_0-2633263_0_0"}}, EnableMonitorDeletion: false}
config := ReadConfig("test-config.yaml")

Expand All @@ -32,7 +32,7 @@ func TestConfigWithIncorrectEnableFlag(t *testing.T){
}
}

func TestConfigWithoutProvider(t *testing.T){
func TestConfigWithoutProvider(t *testing.T) {
incorrectConifg := Config{Providers: []Provider{}, EnableMonitorDeletion: false}
config := ReadConfig("test-config.yaml")

Expand All @@ -41,7 +41,7 @@ func TestConfigWithoutProvider(t *testing.T){
}
}

func TestConfigWithoutEnabledFlag(t *testing.T){
func TestConfigWithoutEnabledFlag(t *testing.T) {
incorrectConifg := Config{Providers: []Provider{Provider{Name: "UptimeRobot", ApiKey: "657a68d9ashdyasjdklkskuasd", ApiURL: "https://api.uptimerobot.com/v2/", AlertContacts: "0544483_0_0-2628365_0_0-2633263_0_0"}}}
config := ReadConfig("test-config.yaml")

Expand All @@ -50,11 +50,11 @@ func TestConfigWithoutEnabledFlag(t *testing.T){
}
}

func TestConfigWithEmptyConfig(t *testing.T){
func TestConfigWithEmptyConfig(t *testing.T) {
incorrectConifg := Config{}
config := ReadConfig("test-config.yaml")

if reflect.DeepEqual(config, incorrectConifg) {
t.Error("Marshalled config and incorrect config match, should not match")
}
}
}
Loading