f
This commit is contained in:
28
internal/shared/fadada/errors_test.go
Normal file
28
internal/shared/fadada/errors_test.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package fadada
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestIsAuthAlreadyGranted(t *testing.T) {
|
||||
if !IsAuthAlreadyGranted(NewAPIError("op", CodeAuthScopeDuplicate, "授权范围重复获取", "1")) {
|
||||
t.Fatal("210002 should match")
|
||||
}
|
||||
if !IsAuthAlreadyGranted(NewAPIError("op", CodeAuthScopeDuplicateCorp, "授权范围重复获取", "2")) {
|
||||
t.Fatal("210013 should match")
|
||||
}
|
||||
if IsAuthAlreadyGranted(NewAPIError("op", CodeParamIllegal, "请求参数非法", "3")) {
|
||||
t.Fatal("100011 should not match")
|
||||
}
|
||||
if !IsAuthAlreadyGranted(fmt.Errorf("wrap: %w", NewAPIError("op", CodeAuthScopeDuplicate, "x", "4"))) {
|
||||
t.Fatal("wrapped 210002 should match")
|
||||
}
|
||||
if !IsAuthAlreadyGranted(errors.New("fail: code=210013 msg=授权范围重复获取 requestId=x")) {
|
||||
t.Fatal("legacy string 210013 should match")
|
||||
}
|
||||
if IsAuthAlreadyGranted(errors.New("无需重复操作")) {
|
||||
t.Fatal("msg-only must not match per official docs")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user