Apply .gitignore rules

This commit is contained in:
皮蛋13361098506
2025-01-06 16:21:36 +08:00
parent 1b77f62820
commit ccd2c530cf
580 changed files with 69806 additions and 0 deletions

View File

@@ -0,0 +1,47 @@
package shortUrlMgr
import (
"fmt"
"testing"
)
func TestShortUrl(t *testing.T) {
// ShortUrl_SERVICE_URL = "http://a.app366.com/get"
appId := "unittest"
appId_wrong := "wrong"
appSecret := "c5746980-5d52-4ba9-834f-13d0066ad1d0"
appSecret_wrong := "wrong"
fullUrl := "http://unittest.PlayerId=123&Name=Jordan"
fullUrl_wrong := ""
timeout := 3
// Test with wrong AppId
shortUrl, err := GetShortUrl(appId_wrong, appSecret, fullUrl, timeout)
if err == nil {
t.Errorf("There should be an error, but now there is no error")
return
}
// Test with wrong AppSecret
shortUrl, err = GetShortUrl(appId, appSecret_wrong, fullUrl, timeout)
if err == nil {
t.Errorf("There should be an error, but now there is no error")
return
}
// Test with wrong FullUrl
shortUrl, err = GetShortUrl(appId, appSecret, fullUrl_wrong, timeout)
if err == nil {
t.Errorf("There should be an error, but now there is no error")
return
}
// Test with correct information and domestic ip
shortUrl, err = GetShortUrl(appId, appSecret, fullUrl, timeout)
if err != nil {
t.Errorf("There should be no error, but now there is one:%s", err)
return
}
fmt.Printf("shortUrl:%v\n", shortUrl)
}