From 01233d3c0a00ba334dfd5841a8ed1c8a71bdbee7 Mon Sep 17 00:00:00 2001 From: Simon Bein Date: Sun, 7 Oct 2018 16:57:53 +0200 Subject: [PATCH] Add a unit test for DetermineAction (#12) * Add a unit test for DetermineAction --- .circleci/config.yml | 2 +- main_test.go | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 88fbcd3..a65543d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -22,7 +22,7 @@ jobs: environment: TEST_RES_DIR: /tmp/test-results ARTIFACTS_DIR: /tmp/artifacts - APP_VERSION: v0.5.0 + APP_VERSION: v0.5.1 steps: - checkout - run: diff --git a/main_test.go b/main_test.go index 5c6c6e1..b2737e8 100644 --- a/main_test.go +++ b/main_test.go @@ -116,3 +116,39 @@ func TestParseConfig(t *testing.T) { }) } } + +func TestDetermineActions(t *testing.T) { + // Test Default Case + if determineActions("") != nil { + t.Errorf("Calling determineActions with no parameters, should return nil") + } + + if determineActions("does-not-exist") != nil { + t.Errorf("Calling determinActions with an invalid parameter, should return nil") + } + + // Test Version Case + if determineActions("version") != nil { + t.Errorf("Calling determinActions with the version flag, should return nil") + } + + // Set Up some sample apps + curConfig.AffectedApps = []string{ + "Calendar", + "Messages", + } + + // Test On Case + res := determineActions("on") + + if len(res) != len(curConfig.AffectedApps)+1 { //plus 1 for Notification Center + t.Errorf("len res %d, len curConfig %d", len(res), len(curConfig.AffectedApps)) + } + + // Test Off Case + res = determineActions("off") + + if len(res) != len(curConfig.AffectedApps)+1 { //plus 1 for Notification Center + t.Errorf("len res %d, len curConfig %d", len(res), len(curConfig.AffectedApps)) + } +}