-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathk8s_test.go
32 lines (29 loc) · 909 Bytes
/
k8s_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package main
import (
"k8s.io/client-go/kubernetes/fake"
"testing"
)
func TestScrapeIngressesForAllNamespaces(t *testing.T) {
rules := generateRules("./examples/ingressList.json")
client := fake.NewSimpleClientset(&rules)
irules, err := ScrapeIngresses(client, "")
if err != nil {
t.Errorf("Something went wrong scraping ingress for rules: %s\n", err)
return
}
if len(irules.Items) != 2 {
t.Errorf("Didn't scrape all rules, got: %d, expected: %d ", irules.Size(), 2)
}
}
func TestScrapeIngressesForAGivenNamespace(t *testing.T) {
rules := generateRules("./examples/ingressList.json")
client := fake.NewSimpleClientset(&rules)
irules, err := ScrapeIngresses(client, "ns1")
if err != nil {
t.Errorf("Something went wrong scraping ingress for rules: %s\n", err)
return
}
if len(irules.Items) != 1 {
t.Errorf("Didn't scrape all rules, got: %d, expected: %d ", irules.Size(), 2)
}
}