-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add tests in pkg/controller/utils (#116)
* add tests in pkg/controller/utils
- Loading branch information
1 parent
9632c83
commit 7b2abf1
Showing
6 changed files
with
603 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Unless explicitly stated otherwise all files in this repository are licensed | ||
// under the Apache License Version 2.0. | ||
// This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
// Copyright 2016-2019 Datadog, Inc. | ||
|
||
package utils | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestContainsString(t *testing.T) { | ||
list := []string{ | ||
"hello", | ||
"goodbye", | ||
"see you", | ||
"hi!", | ||
} | ||
s := "hi!" | ||
containsString := ContainsString(list, s) | ||
assert.True(t, containsString) | ||
|
||
s = "see you?" | ||
containsString = ContainsString(list, s) | ||
assert.False(t, containsString) | ||
|
||
s = "see" | ||
containsString = ContainsString(list, s) | ||
assert.False(t, containsString) | ||
|
||
s = "see you" | ||
containsString = ContainsString(list, s) | ||
assert.True(t, containsString) | ||
} | ||
|
||
func TestRemoveString(t *testing.T) { | ||
list := []string{ | ||
"hello", | ||
"goodbye", | ||
"see you", | ||
"hi!", | ||
} | ||
s := "hi!" | ||
result := RemoveString(list, s) | ||
assert.NotContains(t, result, s) | ||
|
||
s = "see you?" | ||
result = RemoveString(list, s) | ||
assert.Equal(t, list, result) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.