Skip to content

Commit 0a2a185

Browse files
committed
rebase
1 parent f09bc3d commit 0a2a185

File tree

8 files changed

+1213
-1213
lines changed

8 files changed

+1213
-1213
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ require (
1111
github.com/prometheus/client_golang v1.19.1
1212
github.com/prometheus/common v0.55.0
1313
github.com/stretchr/testify v1.9.0
14+
golang.org/x/sync v0.7.0
1415
k8s.io/api v0.30.2
1516
k8s.io/apimachinery v0.30.2
1617
k8s.io/client-go v0.30.2
1718
k8s.io/klog/v2 v2.130.1
1819
k8s.io/utils v0.0.0-20240502163921-fe8a2dddb1d0
19-
golang.org/x/sync v0.7.0
2020
sigs.k8s.io/controller-runtime v0.18.4
2121
)
2222

Lines changed: 161 additions & 161 deletions
Original file line numberDiff line numberDiff line change
@@ -1,161 +1,161 @@
1-
/*
2-
Copyright (c) Microsoft Corporation.
3-
Licensed under the MIT license.
4-
*/
5-
6-
package azureerrors
7-
8-
import (
9-
"errors"
10-
"testing"
11-
12-
"github.com/Azure/azure-sdk-for-go/sdk/azcore"
13-
)
14-
15-
func TestIsNotFound(t *testing.T) {
16-
tests := []struct {
17-
name string
18-
err error
19-
want bool
20-
}{
21-
{
22-
name: "nil error",
23-
err: nil,
24-
want: false,
25-
},
26-
{
27-
name: "not azure error",
28-
err: errors.New("not azure error"),
29-
want: false,
30-
},
31-
{
32-
name: "bad request error",
33-
err: &azcore.ResponseError{StatusCode: 400},
34-
want: false,
35-
},
36-
{
37-
name: "not found error",
38-
err: &azcore.ResponseError{StatusCode: 404},
39-
want: true,
40-
},
41-
}
42-
for _, tc := range tests {
43-
t.Run(tc.name, func(t *testing.T) {
44-
got := IsNotFound(tc.err)
45-
if got != tc.want {
46-
t.Errorf("IsNotFound() = %v, want %v", got, tc.want)
47-
}
48-
})
49-
}
50-
}
51-
52-
func TestIsClientError(t *testing.T) {
53-
tests := []struct {
54-
name string
55-
err error
56-
want bool
57-
}{
58-
{
59-
name: "nil error",
60-
err: nil,
61-
want: false,
62-
},
63-
{
64-
name: "not azure error",
65-
err: errors.New("not azure error"),
66-
want: false,
67-
},
68-
{
69-
name: "bad request error",
70-
err: &azcore.ResponseError{StatusCode: 400},
71-
want: true,
72-
},
73-
{
74-
name: "not found error",
75-
err: &azcore.ResponseError{StatusCode: 404},
76-
want: true,
77-
},
78-
}
79-
for _, tc := range tests {
80-
t.Run(tc.name, func(t *testing.T) {
81-
got := IsClientError(tc.err)
82-
if got != tc.want {
83-
t.Errorf("IsClientError() = %v, want %v", got, tc.want)
84-
}
85-
})
86-
}
87-
}
88-
89-
func TestIsConflict(t *testing.T) {
90-
tests := []struct {
91-
name string
92-
err error
93-
want bool
94-
}{
95-
{
96-
name: "nil error",
97-
err: nil,
98-
want: false,
99-
},
100-
{
101-
name: "not azure error",
102-
err: errors.New("not azure error"),
103-
want: false,
104-
},
105-
{
106-
name: "bad request error",
107-
err: &azcore.ResponseError{StatusCode: 400},
108-
want: false,
109-
},
110-
{
111-
name: "conflict error",
112-
err: &azcore.ResponseError{StatusCode: 409},
113-
want: true,
114-
},
115-
}
116-
for _, tc := range tests {
117-
t.Run(tc.name, func(t *testing.T) {
118-
got := IsConflict(tc.err)
119-
if got != tc.want {
120-
t.Errorf("IsConflict() = %v, want %v", got, tc.want)
121-
}
122-
})
123-
}
124-
}
125-
126-
func TestIsThrottled(t *testing.T) {
127-
tests := []struct {
128-
name string
129-
err error
130-
want bool
131-
}{
132-
{
133-
name: "nil error",
134-
err: nil,
135-
want: false,
136-
},
137-
{
138-
name: "not azure error",
139-
err: errors.New("not azure error"),
140-
want: false,
141-
},
142-
{
143-
name: "bad request error",
144-
err: &azcore.ResponseError{StatusCode: 400},
145-
want: false,
146-
},
147-
{
148-
name: "throttled error",
149-
err: &azcore.ResponseError{StatusCode: 429},
150-
want: true,
151-
},
152-
}
153-
for _, tc := range tests {
154-
t.Run(tc.name, func(t *testing.T) {
155-
got := IsThrottled(tc.err)
156-
if got != tc.want {
157-
t.Errorf("IsConflict() = %v, want %v", got, tc.want)
158-
}
159-
})
160-
}
161-
}
1+
/*
2+
Copyright (c) Microsoft Corporation.
3+
Licensed under the MIT license.
4+
*/
5+
6+
package azureerrors
7+
8+
import (
9+
"errors"
10+
"testing"
11+
12+
"github.com/Azure/azure-sdk-for-go/sdk/azcore"
13+
)
14+
15+
func TestIsNotFound(t *testing.T) {
16+
tests := []struct {
17+
name string
18+
err error
19+
want bool
20+
}{
21+
{
22+
name: "nil error",
23+
err: nil,
24+
want: false,
25+
},
26+
{
27+
name: "not azure error",
28+
err: errors.New("not azure error"),
29+
want: false,
30+
},
31+
{
32+
name: "bad request error",
33+
err: &azcore.ResponseError{StatusCode: 400},
34+
want: false,
35+
},
36+
{
37+
name: "not found error",
38+
err: &azcore.ResponseError{StatusCode: 404},
39+
want: true,
40+
},
41+
}
42+
for _, tc := range tests {
43+
t.Run(tc.name, func(t *testing.T) {
44+
got := IsNotFound(tc.err)
45+
if got != tc.want {
46+
t.Errorf("IsNotFound() = %v, want %v", got, tc.want)
47+
}
48+
})
49+
}
50+
}
51+
52+
func TestIsClientError(t *testing.T) {
53+
tests := []struct {
54+
name string
55+
err error
56+
want bool
57+
}{
58+
{
59+
name: "nil error",
60+
err: nil,
61+
want: false,
62+
},
63+
{
64+
name: "not azure error",
65+
err: errors.New("not azure error"),
66+
want: false,
67+
},
68+
{
69+
name: "bad request error",
70+
err: &azcore.ResponseError{StatusCode: 400},
71+
want: true,
72+
},
73+
{
74+
name: "not found error",
75+
err: &azcore.ResponseError{StatusCode: 404},
76+
want: true,
77+
},
78+
}
79+
for _, tc := range tests {
80+
t.Run(tc.name, func(t *testing.T) {
81+
got := IsClientError(tc.err)
82+
if got != tc.want {
83+
t.Errorf("IsClientError() = %v, want %v", got, tc.want)
84+
}
85+
})
86+
}
87+
}
88+
89+
func TestIsConflict(t *testing.T) {
90+
tests := []struct {
91+
name string
92+
err error
93+
want bool
94+
}{
95+
{
96+
name: "nil error",
97+
err: nil,
98+
want: false,
99+
},
100+
{
101+
name: "not azure error",
102+
err: errors.New("not azure error"),
103+
want: false,
104+
},
105+
{
106+
name: "bad request error",
107+
err: &azcore.ResponseError{StatusCode: 400},
108+
want: false,
109+
},
110+
{
111+
name: "conflict error",
112+
err: &azcore.ResponseError{StatusCode: 409},
113+
want: true,
114+
},
115+
}
116+
for _, tc := range tests {
117+
t.Run(tc.name, func(t *testing.T) {
118+
got := IsConflict(tc.err)
119+
if got != tc.want {
120+
t.Errorf("IsConflict() = %v, want %v", got, tc.want)
121+
}
122+
})
123+
}
124+
}
125+
126+
func TestIsThrottled(t *testing.T) {
127+
tests := []struct {
128+
name string
129+
err error
130+
want bool
131+
}{
132+
{
133+
name: "nil error",
134+
err: nil,
135+
want: false,
136+
},
137+
{
138+
name: "not azure error",
139+
err: errors.New("not azure error"),
140+
want: false,
141+
},
142+
{
143+
name: "bad request error",
144+
err: &azcore.ResponseError{StatusCode: 400},
145+
want: false,
146+
},
147+
{
148+
name: "throttled error",
149+
err: &azcore.ResponseError{StatusCode: 429},
150+
want: true,
151+
},
152+
}
153+
for _, tc := range tests {
154+
t.Run(tc.name, func(t *testing.T) {
155+
got := IsThrottled(tc.err)
156+
if got != tc.want {
157+
t.Errorf("IsConflict() = %v, want %v", got, tc.want)
158+
}
159+
})
160+
}
161+
}

0 commit comments

Comments
 (0)