generated: run refactor

This commit is contained in:
Mike Danese
2020-02-07 18:16:47 -08:00
parent 7e88d8db66
commit 3aa59f7f30
697 changed files with 4380 additions and 3806 deletions

View File

@@ -17,6 +17,7 @@ limitations under the License.
package tests
import (
"context"
"testing"
corev1 "k8s.io/api/core/v1"
@@ -37,7 +38,7 @@ func TestFakeClientSetFiltering(t *testing.T) {
testSA("nsB", "sa-3"),
)
saList1, err := tc.CoreV1().ServiceAccounts("nsA").List(metav1.ListOptions{})
saList1, err := tc.CoreV1().ServiceAccounts("nsA").List(context.TODO(), metav1.ListOptions{})
if err != nil {
t.Fatalf("ServiceAccounts.List: %s", err)
}
@@ -50,7 +51,7 @@ func TestFakeClientSetFiltering(t *testing.T) {
}
}
saList2, err := tc.CoreV1().ServiceAccounts("nsB").List(metav1.ListOptions{})
saList2, err := tc.CoreV1().ServiceAccounts("nsB").List(context.TODO(), metav1.ListOptions{})
if err != nil {
t.Fatalf("ServiceAccounts.List: %s", err)
}
@@ -63,7 +64,7 @@ func TestFakeClientSetFiltering(t *testing.T) {
}
}
pod1, err := tc.CoreV1().Pods("nsA").Get("pod-1", metav1.GetOptions{})
pod1, err := tc.CoreV1().Pods("nsA").Get(context.TODO(), "pod-1", metav1.GetOptions{})
if err != nil {
t.Fatalf("Pods.Get: %s", err)
}
@@ -74,12 +75,12 @@ func TestFakeClientSetFiltering(t *testing.T) {
t.Fatalf("Expected to find pod nsA/pod-1t, got %s/%s", pod1.Namespace, pod1.Name)
}
wrongPod, err := tc.CoreV1().Pods("nsB").Get("pod-1", metav1.GetOptions{})
wrongPod, err := tc.CoreV1().Pods("nsB").Get(context.TODO(), "pod-1", metav1.GetOptions{})
if err == nil {
t.Fatalf("Pods.Get: expected nsB/pod-1 not to match, but it matched %s/%s", wrongPod.Namespace, wrongPod.Name)
}
allPods, err := tc.CoreV1().Pods(metav1.NamespaceAll).List(metav1.ListOptions{})
allPods, err := tc.CoreV1().Pods(metav1.NamespaceAll).List(context.TODO(), metav1.ListOptions{})
if err != nil {
t.Fatalf("Pods.List: %s", err)
}
@@ -87,7 +88,7 @@ func TestFakeClientSetFiltering(t *testing.T) {
t.Fatalf("Expected %d pods to match, got %d", expected, actual)
}
allSAs, err := tc.CoreV1().ServiceAccounts(metav1.NamespaceAll).List(metav1.ListOptions{})
allSAs, err := tc.CoreV1().ServiceAccounts(metav1.NamespaceAll).List(context.TODO(), metav1.ListOptions{})
if err != nil {
t.Fatalf("ServiceAccounts.List: %s", err)
}
@@ -102,12 +103,12 @@ func TestFakeClientsetInheritsNamespace(t *testing.T) {
testPod("nsA", "pod-1"),
)
_, err := tc.CoreV1().Namespaces().Create(testNamespace("nsB"))
_, err := tc.CoreV1().Namespaces().Create(context.TODO(), testNamespace("nsB"))
if err != nil {
t.Fatalf("Namespaces.Create: %s", err)
}
allNS, err := tc.CoreV1().Namespaces().List(metav1.ListOptions{})
allNS, err := tc.CoreV1().Namespaces().List(context.TODO(), metav1.ListOptions{})
if err != nil {
t.Fatalf("Namespaces.List: %s", err)
}
@@ -115,12 +116,12 @@ func TestFakeClientsetInheritsNamespace(t *testing.T) {
t.Fatalf("Expected %d namespaces to match, got %d", expected, actual)
}
_, err = tc.CoreV1().Pods("nsB").Create(testPod("", "pod-1"))
_, err = tc.CoreV1().Pods("nsB").Create(context.TODO(), testPod("", "pod-1"))
if err != nil {
t.Fatalf("Pods.Create nsB/pod-1: %s", err)
}
podB1, err := tc.CoreV1().Pods("nsB").Get("pod-1", metav1.GetOptions{})
podB1, err := tc.CoreV1().Pods("nsB").Get(context.TODO(), "pod-1", metav1.GetOptions{})
if err != nil {
t.Fatalf("Pods.Get nsB/pod-1: %s", err)
}
@@ -131,17 +132,17 @@ func TestFakeClientsetInheritsNamespace(t *testing.T) {
t.Fatalf("Expected to find pod nsB/pod-1t, got %s/%s", podB1.Namespace, podB1.Name)
}
_, err = tc.CoreV1().Pods("nsA").Create(testPod("", "pod-1"))
_, err = tc.CoreV1().Pods("nsA").Create(context.TODO(), testPod("", "pod-1"))
if err == nil {
t.Fatalf("Expected Pods.Create to fail with already exists error")
}
_, err = tc.CoreV1().Pods("nsA").Update(testPod("", "pod-1"))
_, err = tc.CoreV1().Pods("nsA").Update(context.TODO(), testPod("", "pod-1"))
if err != nil {
t.Fatalf("Pods.Update nsA/pod-1: %s", err)
}
_, err = tc.CoreV1().Pods("nsA").Create(testPod("nsB", "pod-2"))
_, err = tc.CoreV1().Pods("nsA").Create(context.TODO(), testPod("nsB", "pod-2"))
if err == nil {
t.Fatalf("Expected Pods.Create to fail with bad request from namespace mismtach")
}
@@ -149,7 +150,7 @@ func TestFakeClientsetInheritsNamespace(t *testing.T) {
t.Fatalf("Expected Pods.Create error to provide object and request namespaces, got %q", err)
}
_, err = tc.CoreV1().Pods("nsA").Update(testPod("", "pod-3"))
_, err = tc.CoreV1().Pods("nsA").Update(context.TODO(), testPod("", "pod-3"))
if err == nil {
t.Fatalf("Expected Pods.Update nsA/pod-3 to fail with not found error")
}