Skip to content

Commit

Permalink
Merge pull request #4 from stakater/test-cases
Browse files Browse the repository at this point in the history
[STK-114] Add Test cases
  • Loading branch information
hazim1093 authored Feb 27, 2018
2 parents 0e56188 + c31d07a commit fee141b
Show file tree
Hide file tree
Showing 9 changed files with 734 additions and 48 deletions.
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

0 comments on commit fee141b

Please sign in to comment.