Initial release of bdrclone

This commit is contained in:
2026-08-13 23:02:25 +08:00
commit d6d1956050
23 changed files with 3042 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
package auth
import "testing"
func TestParseAuthorizationCode(t *testing.T) {
tests := map[string]string{
"plain-code\n": "plain-code",
"http://openapi.baidu.com/success?code=a%2Bb": "a+b",
"https://example.test/?state=x&code=xyz": "xyz",
}
for input, want := range tests {
got, err := parseAuthorizationCode(input)
if err != nil {
t.Fatalf("parseAuthorizationCode(%q): %v", input, err)
}
if got != want {
t.Errorf("parseAuthorizationCode(%q) = %q, want %q", input, got, want)
}
}
for _, input := range []string{"", " \n", "two words"} {
if _, err := parseAuthorizationCode(input); err == nil {
t.Errorf("parseAuthorizationCode(%q) unexpectedly succeeded", input)
}
}
}