-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f09bc3d
commit 0a2a185
Showing
8 changed files
with
1,213 additions
and
1,213 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,161 +1,161 @@ | ||
/* | ||
Copyright (c) Microsoft Corporation. | ||
Licensed under the MIT license. | ||
*/ | ||
|
||
package azureerrors | ||
|
||
import ( | ||
"errors" | ||
"testing" | ||
|
||
"github.com/Azure/azure-sdk-for-go/sdk/azcore" | ||
) | ||
|
||
func TestIsNotFound(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
err error | ||
want bool | ||
}{ | ||
{ | ||
name: "nil error", | ||
err: nil, | ||
want: false, | ||
}, | ||
{ | ||
name: "not azure error", | ||
err: errors.New("not azure error"), | ||
want: false, | ||
}, | ||
{ | ||
name: "bad request error", | ||
err: &azcore.ResponseError{StatusCode: 400}, | ||
want: false, | ||
}, | ||
{ | ||
name: "not found error", | ||
err: &azcore.ResponseError{StatusCode: 404}, | ||
want: true, | ||
}, | ||
} | ||
for _, tc := range tests { | ||
t.Run(tc.name, func(t *testing.T) { | ||
got := IsNotFound(tc.err) | ||
if got != tc.want { | ||
t.Errorf("IsNotFound() = %v, want %v", got, tc.want) | ||
} | ||
}) | ||
} | ||
} | ||
|
||
func TestIsClientError(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
err error | ||
want bool | ||
}{ | ||
{ | ||
name: "nil error", | ||
err: nil, | ||
want: false, | ||
}, | ||
{ | ||
name: "not azure error", | ||
err: errors.New("not azure error"), | ||
want: false, | ||
}, | ||
{ | ||
name: "bad request error", | ||
err: &azcore.ResponseError{StatusCode: 400}, | ||
want: true, | ||
}, | ||
{ | ||
name: "not found error", | ||
err: &azcore.ResponseError{StatusCode: 404}, | ||
want: true, | ||
}, | ||
} | ||
for _, tc := range tests { | ||
t.Run(tc.name, func(t *testing.T) { | ||
got := IsClientError(tc.err) | ||
if got != tc.want { | ||
t.Errorf("IsClientError() = %v, want %v", got, tc.want) | ||
} | ||
}) | ||
} | ||
} | ||
|
||
func TestIsConflict(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
err error | ||
want bool | ||
}{ | ||
{ | ||
name: "nil error", | ||
err: nil, | ||
want: false, | ||
}, | ||
{ | ||
name: "not azure error", | ||
err: errors.New("not azure error"), | ||
want: false, | ||
}, | ||
{ | ||
name: "bad request error", | ||
err: &azcore.ResponseError{StatusCode: 400}, | ||
want: false, | ||
}, | ||
{ | ||
name: "conflict error", | ||
err: &azcore.ResponseError{StatusCode: 409}, | ||
want: true, | ||
}, | ||
} | ||
for _, tc := range tests { | ||
t.Run(tc.name, func(t *testing.T) { | ||
got := IsConflict(tc.err) | ||
if got != tc.want { | ||
t.Errorf("IsConflict() = %v, want %v", got, tc.want) | ||
} | ||
}) | ||
} | ||
} | ||
|
||
func TestIsThrottled(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
err error | ||
want bool | ||
}{ | ||
{ | ||
name: "nil error", | ||
err: nil, | ||
want: false, | ||
}, | ||
{ | ||
name: "not azure error", | ||
err: errors.New("not azure error"), | ||
want: false, | ||
}, | ||
{ | ||
name: "bad request error", | ||
err: &azcore.ResponseError{StatusCode: 400}, | ||
want: false, | ||
}, | ||
{ | ||
name: "throttled error", | ||
err: &azcore.ResponseError{StatusCode: 429}, | ||
want: true, | ||
}, | ||
} | ||
for _, tc := range tests { | ||
t.Run(tc.name, func(t *testing.T) { | ||
got := IsThrottled(tc.err) | ||
if got != tc.want { | ||
t.Errorf("IsConflict() = %v, want %v", got, tc.want) | ||
} | ||
}) | ||
} | ||
} | ||
/* | ||
Copyright (c) Microsoft Corporation. | ||
Licensed under the MIT license. | ||
*/ | ||
|
||
package azureerrors | ||
|
||
import ( | ||
"errors" | ||
"testing" | ||
|
||
"github.com/Azure/azure-sdk-for-go/sdk/azcore" | ||
) | ||
|
||
func TestIsNotFound(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
err error | ||
want bool | ||
}{ | ||
{ | ||
name: "nil error", | ||
err: nil, | ||
want: false, | ||
}, | ||
{ | ||
name: "not azure error", | ||
err: errors.New("not azure error"), | ||
want: false, | ||
}, | ||
{ | ||
name: "bad request error", | ||
err: &azcore.ResponseError{StatusCode: 400}, | ||
want: false, | ||
}, | ||
{ | ||
name: "not found error", | ||
err: &azcore.ResponseError{StatusCode: 404}, | ||
want: true, | ||
}, | ||
} | ||
for _, tc := range tests { | ||
t.Run(tc.name, func(t *testing.T) { | ||
got := IsNotFound(tc.err) | ||
if got != tc.want { | ||
t.Errorf("IsNotFound() = %v, want %v", got, tc.want) | ||
} | ||
}) | ||
} | ||
} | ||
|
||
func TestIsClientError(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
err error | ||
want bool | ||
}{ | ||
{ | ||
name: "nil error", | ||
err: nil, | ||
want: false, | ||
}, | ||
{ | ||
name: "not azure error", | ||
err: errors.New("not azure error"), | ||
want: false, | ||
}, | ||
{ | ||
name: "bad request error", | ||
err: &azcore.ResponseError{StatusCode: 400}, | ||
want: true, | ||
}, | ||
{ | ||
name: "not found error", | ||
err: &azcore.ResponseError{StatusCode: 404}, | ||
want: true, | ||
}, | ||
} | ||
for _, tc := range tests { | ||
t.Run(tc.name, func(t *testing.T) { | ||
got := IsClientError(tc.err) | ||
if got != tc.want { | ||
t.Errorf("IsClientError() = %v, want %v", got, tc.want) | ||
} | ||
}) | ||
} | ||
} | ||
|
||
func TestIsConflict(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
err error | ||
want bool | ||
}{ | ||
{ | ||
name: "nil error", | ||
err: nil, | ||
want: false, | ||
}, | ||
{ | ||
name: "not azure error", | ||
err: errors.New("not azure error"), | ||
want: false, | ||
}, | ||
{ | ||
name: "bad request error", | ||
err: &azcore.ResponseError{StatusCode: 400}, | ||
want: false, | ||
}, | ||
{ | ||
name: "conflict error", | ||
err: &azcore.ResponseError{StatusCode: 409}, | ||
want: true, | ||
}, | ||
} | ||
for _, tc := range tests { | ||
t.Run(tc.name, func(t *testing.T) { | ||
got := IsConflict(tc.err) | ||
if got != tc.want { | ||
t.Errorf("IsConflict() = %v, want %v", got, tc.want) | ||
} | ||
}) | ||
} | ||
} | ||
|
||
func TestIsThrottled(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
err error | ||
want bool | ||
}{ | ||
{ | ||
name: "nil error", | ||
err: nil, | ||
want: false, | ||
}, | ||
{ | ||
name: "not azure error", | ||
err: errors.New("not azure error"), | ||
want: false, | ||
}, | ||
{ | ||
name: "bad request error", | ||
err: &azcore.ResponseError{StatusCode: 400}, | ||
want: false, | ||
}, | ||
{ | ||
name: "throttled error", | ||
err: &azcore.ResponseError{StatusCode: 429}, | ||
want: true, | ||
}, | ||
} | ||
for _, tc := range tests { | ||
t.Run(tc.name, func(t *testing.T) { | ||
got := IsThrottled(tc.err) | ||
if got != tc.want { | ||
t.Errorf("IsConflict() = %v, want %v", got, tc.want) | ||
} | ||
}) | ||
} | ||
} |
Oops, something went wrong.