Skip to content

Commit b187c4f

Browse files
CodeSpaceiiiiPanPanZou
authored andcommitted
Update error assertions in proxy tests for improved clarity
- Add checks for non-nil errors in TestRAMRoleARNWithInvalidProxy and TestOIDCWithInvalidProxy. - Modify error message assertions to allow for variations in connection refusal messages, enhancing compatibility across platforms.
1 parent 9282a85 commit b187c4f

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

integration/proxy/proxy_test.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package proxy
22

33
import (
44
"os"
5+
"strings"
56
"testing"
67

78
"github.com/alibabacloud-go/tea/tea"
@@ -22,8 +23,10 @@ func TestRAMRoleARNWithInvalidProxy(t *testing.T) {
2223
cred, err := credentials.NewCredential(config)
2324
assert.Nil(t, err)
2425
_, err = cred.GetCredential()
26+
assert.NotNil(t, err)
2527
assert.Contains(t, err.Error(), "proxyconnect tcp: dial tcp")
26-
assert.Contains(t, err.Error(), ":3600: connect: connection refused")
28+
assert.Contains(t, err.Error(), ":3600")
29+
assert.True(t, strings.Contains(err.Error(), "connection refused") || strings.Contains(err.Error(), "No connection could be made"))
2730
}
2831

2932
func TestOIDCWithInvalidProxy(t *testing.T) {
@@ -38,6 +41,8 @@ func TestOIDCWithInvalidProxy(t *testing.T) {
3841
cred, err := credentials.NewCredential(config)
3942
assert.Nil(t, err)
4043
_, err = cred.GetCredential()
44+
assert.NotNil(t, err)
4145
assert.Contains(t, err.Error(), "proxyconnect tcp: dial tcp")
42-
assert.Contains(t, err.Error(), ":3600: connect: connection refused")
46+
assert.Contains(t, err.Error(), ":3600")
47+
assert.True(t, strings.Contains(err.Error(), "connection refused") || strings.Contains(err.Error(), "No connection could be made"))
4348
}

0 commit comments

Comments
 (0)