feat: 实现联通话费余量只读面板
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
package unicom
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestLiveDiscover(t *testing.T) {
|
||||
if os.Getenv("CU_LIVE") == "" {
|
||||
t.Skip()
|
||||
}
|
||||
client, err := New()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 70*time.Second)
|
||||
defer cancel()
|
||||
if err := client.Prepare(ctx); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
script, appID := client.Captcha()
|
||||
if script == "" || appID == "" {
|
||||
t.Fatalf("captcha script=%q app=%q", script, appID)
|
||||
}
|
||||
client.mu.Lock()
|
||||
err = client.prepareBill(ctx)
|
||||
fee, plan := client.fee.URL, client.plan.URL
|
||||
version := client.fee.Version
|
||||
client.mu.Unlock()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if fee == "" || plan == "" || version == "" {
|
||||
t.Fatalf("fee=%s plan=%s version=%s", fee, plan, version)
|
||||
}
|
||||
t.Logf("captcha app %s fee %s plan %s", appID, fee, plan)
|
||||
}
|
||||
Reference in New Issue
Block a user