|
1 | 1 | package proxy
|
2 | 2 |
|
3 | 3 | import (
|
4 |
| - "context" |
5 | 4 | "strings"
|
6 | 5 | "testing"
|
7 | 6 |
|
8 | 7 | corev1 "k8s.io/api/core/v1"
|
9 | 8 | "k8s.io/apimachinery/pkg/api/errors"
|
10 | 9 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
11 | 10 | "k8s.io/apimachinery/pkg/labels"
|
12 |
| - "k8s.io/apimachinery/pkg/runtime" |
13 | 11 | "k8s.io/apiserver/pkg/authentication/user"
|
14 | 12 | apirequest "k8s.io/apiserver/pkg/endpoints/request"
|
15 | 13 | "k8s.io/apiserver/pkg/registry/rest"
|
@@ -103,27 +101,6 @@ func TestCreateProjectOK(t *testing.T) {
|
103 | 101 | }
|
104 | 102 | }
|
105 | 103 |
|
106 |
| -func TestCreateProjectValidation(t *testing.T) { |
107 |
| - mockClient := &fake.Clientset{} |
108 |
| - storage := NewREST(mockClient.CoreV1().Namespaces(), &mockLister{}, nil, nil) |
109 |
| - |
110 |
| - validationCalled := false |
111 |
| - validationFunc := func(ctx context.Context, obj runtime.Object) error { |
112 |
| - validationCalled = true |
113 |
| - return nil |
114 |
| - } |
115 |
| - |
116 |
| - _, err := storage.Create(apirequest.NewContext(), &projectapi.Project{ |
117 |
| - ObjectMeta: metav1.ObjectMeta{Name: "foo"}, |
118 |
| - }, validationFunc, &metav1.CreateOptions{}) |
119 |
| - if err != nil { |
120 |
| - t.Errorf("Unexpected non-nil error: %#v", err) |
121 |
| - } |
122 |
| - if !validationCalled { |
123 |
| - t.Errorf("Expected validation function to be called") |
124 |
| - } |
125 |
| -} |
126 |
| - |
127 | 104 | func TestGetProjectOK(t *testing.T) {
|
128 | 105 | mockClient := fake.NewSimpleClientset(&corev1.Namespace{ObjectMeta: metav1.ObjectMeta{Name: "foo"}})
|
129 | 106 | storage := NewREST(mockClient.CoreV1().Namespaces(), &mockLister{}, nil, nil)
|
@@ -159,26 +136,9 @@ func TestDeleteProject(t *testing.T) {
|
159 | 136 | t.Errorf("Expected status=success, got: %#v", status)
|
160 | 137 | }
|
161 | 138 | if len(mockClient.Actions()) != 1 {
|
162 |
| - t.Errorf("Expected client action for delete, got %v", mockClient.Actions()) |
| 139 | + t.Errorf("Expected client action for delete") |
163 | 140 | }
|
164 | 141 | if !mockClient.Actions()[0].Matches("delete", "namespaces") {
|
165 |
| - t.Errorf("Expected call to delete-namespace, got %#v", mockClient.Actions()[0]) |
166 |
| - } |
167 |
| -} |
168 |
| - |
169 |
| -func TestDeleteProjectValidation(t *testing.T) { |
170 |
| - mockClient := &fake.Clientset{} |
171 |
| - storage := REST{ |
172 |
| - client: mockClient.CoreV1().Namespaces(), |
173 |
| - } |
174 |
| - validationCalled := false |
175 |
| - validationFunc := func(ctx context.Context, obj runtime.Object) error { |
176 |
| - validationCalled = true |
177 |
| - return nil |
178 |
| - } |
179 |
| - |
180 |
| - storage.Delete(apirequest.NewContext(), "foo", validationFunc, &metav1.DeleteOptions{}) |
181 |
| - if !validationCalled { |
182 |
| - t.Errorf("Expected validation function to be called") |
| 142 | + t.Errorf("Expected call to delete-namespace") |
183 | 143 | }
|
184 | 144 | }
|
0 commit comments