Skip to content

Commit adcd890

Browse files
committed
cleanup: Remove_unnecessary_Sprintfs
Removed unused fmt Signed-off-by: Gaurav Singh <[email protected]>
1 parent 356c121 commit adcd890

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

test/integration/apiserver/max_request_body_bytes_test.go

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ package apiserver
1818

1919
import (
2020
"context"
21-
"fmt"
2221
"strings"
2322
"testing"
2423

@@ -41,7 +40,7 @@ func TestMaxResourceSize(t *testing.T) {
4140

4241
c := clientSet.CoreV1().RESTClient()
4342
t.Run("Create should limit the request body size", func(t *testing.T) {
44-
err := c.Post().AbsPath(fmt.Sprintf("/api/v1/namespaces/default/pods")).
43+
err := c.Post().AbsPath("/api/v1/namespaces/default/pods").
4544
Body(hugeData).Do(context.TODO()).Error()
4645
if err == nil {
4746
t.Fatalf("unexpected no error")
@@ -64,7 +63,7 @@ func TestMaxResourceSize(t *testing.T) {
6463
}
6564

6665
t.Run("Update should limit the request body size", func(t *testing.T) {
67-
err = c.Put().AbsPath(fmt.Sprintf("/api/v1/namespaces/default/secrets/test")).
66+
err = c.Put().AbsPath("/api/v1/namespaces/default/secrets/test").
6867
Body(hugeData).Do(context.TODO()).Error()
6968
if err == nil {
7069
t.Fatalf("unexpected no error")
@@ -75,7 +74,7 @@ func TestMaxResourceSize(t *testing.T) {
7574
}
7675
})
7776
t.Run("Patch should limit the request body size", func(t *testing.T) {
78-
err = c.Patch(types.JSONPatchType).AbsPath(fmt.Sprintf("/api/v1/namespaces/default/secrets/test")).
77+
err = c.Patch(types.JSONPatchType).AbsPath("/api/v1/namespaces/default/secrets/test").
7978
Body(hugeData).Do(context.TODO()).Error()
8079
if err == nil {
8180
t.Fatalf("unexpected no error")
@@ -87,70 +86,70 @@ func TestMaxResourceSize(t *testing.T) {
8786
})
8887
t.Run("JSONPatchType should handle a patch just under the max limit", func(t *testing.T) {
8988
patchBody := []byte(`[{"op":"add","path":"/foo","value":` + strings.Repeat("[", 3*1024*1024/2-100) + strings.Repeat("]", 3*1024*1024/2-100) + `}]`)
90-
err = rest.Patch(types.JSONPatchType).AbsPath(fmt.Sprintf("/api/v1/namespaces/default/secrets/test")).
89+
err = rest.Patch(types.JSONPatchType).AbsPath("/api/v1/namespaces/default/secrets/test").
9190
Body(patchBody).Do(context.TODO()).Error()
9291
if err != nil && !apierrors.IsBadRequest(err) {
9392
t.Errorf("expected success or bad request err, got %v", err)
9493
}
9594
})
9695
t.Run("JSONPatchType should handle a valid patch just under the max limit", func(t *testing.T) {
9796
patchBody := []byte(`[{"op":"add","path":"/foo","value":0` + strings.Repeat(" ", 3*1024*1024-100) + `}]`)
98-
err = rest.Patch(types.JSONPatchType).AbsPath(fmt.Sprintf("/api/v1/namespaces/default/secrets/test")).
97+
err = rest.Patch(types.JSONPatchType).AbsPath("/api/v1/namespaces/default/secrets/test").
9998
Body(patchBody).Do(context.TODO()).Error()
10099
if err != nil {
101100
t.Errorf("unexpected error: %v", err)
102101
}
103102
})
104103
t.Run("MergePatchType should handle a patch just under the max limit", func(t *testing.T) {
105104
patchBody := []byte(`{"value":` + strings.Repeat("[", 3*1024*1024/2-100) + strings.Repeat("]", 3*1024*1024/2-100) + `}`)
106-
err = rest.Patch(types.MergePatchType).AbsPath(fmt.Sprintf("/api/v1/namespaces/default/secrets/test")).
105+
err = rest.Patch(types.MergePatchType).AbsPath("/api/v1/namespaces/default/secrets/test").
107106
Body(patchBody).Do(context.TODO()).Error()
108107
if err != nil && !apierrors.IsBadRequest(err) {
109108
t.Errorf("expected success or bad request err, got %v", err)
110109
}
111110
})
112111
t.Run("MergePatchType should handle a valid patch just under the max limit", func(t *testing.T) {
113112
patchBody := []byte(`{"value":0` + strings.Repeat(" ", 3*1024*1024-100) + `}`)
114-
err = rest.Patch(types.MergePatchType).AbsPath(fmt.Sprintf("/api/v1/namespaces/default/secrets/test")).
113+
err = rest.Patch(types.MergePatchType).AbsPath("/api/v1/namespaces/default/secrets/test").
115114
Body(patchBody).Do(context.TODO()).Error()
116115
if err != nil {
117116
t.Errorf("unexpected error: %v", err)
118117
}
119118
})
120119
t.Run("StrategicMergePatchType should handle a patch just under the max limit", func(t *testing.T) {
121120
patchBody := []byte(`{"value":` + strings.Repeat("[", 3*1024*1024/2-100) + strings.Repeat("]", 3*1024*1024/2-100) + `}`)
122-
err = rest.Patch(types.StrategicMergePatchType).AbsPath(fmt.Sprintf("/api/v1/namespaces/default/secrets/test")).
121+
err = rest.Patch(types.StrategicMergePatchType).AbsPath("/api/v1/namespaces/default/secrets/test").
123122
Body(patchBody).Do(context.TODO()).Error()
124123
if err != nil && !apierrors.IsBadRequest(err) {
125124
t.Errorf("expected success or bad request err, got %v", err)
126125
}
127126
})
128127
t.Run("StrategicMergePatchType should handle a valid patch just under the max limit", func(t *testing.T) {
129128
patchBody := []byte(`{"value":0` + strings.Repeat(" ", 3*1024*1024-100) + `}`)
130-
err = rest.Patch(types.StrategicMergePatchType).AbsPath(fmt.Sprintf("/api/v1/namespaces/default/secrets/test")).
129+
err = rest.Patch(types.StrategicMergePatchType).AbsPath("/api/v1/namespaces/default/secrets/test").
131130
Body(patchBody).Do(context.TODO()).Error()
132131
if err != nil {
133132
t.Errorf("unexpected error: %v", err)
134133
}
135134
})
136135
t.Run("ApplyPatchType should handle a patch just under the max limit", func(t *testing.T) {
137136
patchBody := []byte(`{"value":` + strings.Repeat("[", 3*1024*1024/2-100) + strings.Repeat("]", 3*1024*1024/2-100) + `}`)
138-
err = rest.Patch(types.ApplyPatchType).Param("fieldManager", "test").AbsPath(fmt.Sprintf("/api/v1/namespaces/default/secrets/test")).
137+
err = rest.Patch(types.ApplyPatchType).Param("fieldManager", "test").AbsPath("/api/v1/namespaces/default/secrets/test").
139138
Body(patchBody).Do(context.TODO()).Error()
140139
if err != nil && !apierrors.IsBadRequest(err) {
141140
t.Errorf("expected success or bad request err, got %#v", err)
142141
}
143142
})
144143
t.Run("ApplyPatchType should handle a valid patch just under the max limit", func(t *testing.T) {
145144
patchBody := []byte(`{"apiVersion":"v1","kind":"Secret"` + strings.Repeat(" ", 3*1024*1024-100) + `}`)
146-
err = rest.Patch(types.ApplyPatchType).Param("fieldManager", "test").AbsPath(fmt.Sprintf("/api/v1/namespaces/default/secrets/test")).
145+
err = rest.Patch(types.ApplyPatchType).Param("fieldManager", "test").AbsPath("/api/v1/namespaces/default/secrets/test").
147146
Body(patchBody).Do(context.TODO()).Error()
148147
if err != nil {
149148
t.Errorf("unexpected error: %v", err)
150149
}
151150
})
152151
t.Run("Delete should limit the request body size", func(t *testing.T) {
153-
err = c.Delete().AbsPath(fmt.Sprintf("/api/v1/namespaces/default/secrets/test")).
152+
err = c.Delete().AbsPath("/api/v1/namespaces/default/secrets/test").
154153
Body(hugeData).Do(context.TODO()).Error()
155154
if err == nil {
156155
t.Fatalf("unexpected no error")

0 commit comments

Comments
 (0)