Skip to content

Commit

Permalink
Add a unit test for DetermineAction (#12)
Browse files Browse the repository at this point in the history
* Add a unit test for DetermineAction
  • Loading branch information
SimonTheLeg committed Oct 7, 2018
1 parent 1403745 commit 01233d3
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Expand Up @@ -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:
Expand Down
36 changes: 36 additions & 0 deletions main_test.go
Expand Up @@ -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))
}
}

0 comments on commit 01233d3

Please sign in to comment.