feat(osi): 实现通用 Call 与响应判码(T-004)
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
package osi
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestCodeClassificationNormalizesLeadingZeroes(t *testing.T) {
|
||||
for _, code := range []string{"1", "01", "001"} {
|
||||
if !IsSuccessCode(code) {
|
||||
t.Fatalf("IsSuccessCode(%q) = false", code)
|
||||
}
|
||||
}
|
||||
if IsSuccessCode("0") {
|
||||
t.Fatal("IsSuccessCode accepted zero")
|
||||
}
|
||||
if !IsRetryableCode("405") {
|
||||
t.Fatal("405 should be retryable")
|
||||
}
|
||||
if IsRetryableCode("01") {
|
||||
t.Fatal("success code should not be retryable")
|
||||
}
|
||||
}
|
||||
|
||||
func TestPathOfKnownServiceID(t *testing.T) {
|
||||
path, err := PathOf(ServiceIDJKDAFind)
|
||||
if err != nil {
|
||||
t.Fatalf("PathOf: %v", err)
|
||||
}
|
||||
if path != "/auto/jkda/find" {
|
||||
t.Fatalf("path = %q", path)
|
||||
}
|
||||
if _, err := PathOf("UNKNOWN"); err == nil {
|
||||
t.Fatal("PathOf accepted unknown serviceId")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user