-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #196 from doitintl/fix-helmv2-name
Fix: Helm v3 collector name and refactoring to be test-friendly
- Loading branch information
Showing
9 changed files
with
88 additions
and
19 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
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,28 @@ | ||
package collector | ||
|
||
import ( | ||
"testing" | ||
|
||
"k8s.io/client-go/kubernetes/fake" | ||
) | ||
|
||
func TestNewHelmV2Collector(t *testing.T) { | ||
expectedName := "Helm v2" | ||
|
||
clientSet := fake.NewSimpleClientset() | ||
col, err := NewHelmV2Collector(&HelmV2Opts{ | ||
DiscoveryClient: clientSet.Discovery(), | ||
CoreClient: clientSet.CoreV1(), | ||
}) | ||
clientSet.CoreV1() | ||
|
||
if err != nil { | ||
t.Fatalf("Failed to create collector from fake discovery client") | ||
} | ||
if col == nil { | ||
t.Fatalf("Should return collector, got nil instead") | ||
} | ||
if col.Name() != expectedName { | ||
t.Fatalf("Expected collector name: %s, instead got: %s", expectedName, col.Name()) | ||
} | ||
} |
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,27 @@ | ||
package collector | ||
|
||
import ( | ||
"testing" | ||
|
||
"k8s.io/client-go/kubernetes/fake" | ||
) | ||
|
||
func TestNewHelmV3Collector(t *testing.T) { | ||
expectedName := "Helm v3" | ||
|
||
clientSet := fake.NewSimpleClientset() | ||
col, err := NewHelmV3Collector(&HelmV3Opts{ | ||
DiscoveryClient: clientSet.Discovery(), | ||
CoreClient: clientSet.CoreV1(), | ||
}) | ||
|
||
if err != nil { | ||
t.Fatalf("Failed to create collector from fake discovery client") | ||
} | ||
if col == nil { | ||
t.Fatalf("Should return collector, got nil instead") | ||
} | ||
if col.Name() != expectedName { | ||
t.Fatalf("Expected collector name: %s, instead got: %s", expectedName, col.Name()) | ||
} | ||
} |
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