api_test.go 905 B

12345678910111213141516171819202122232425262728
  1. package archive
  2. import (
  3. "context"
  4. "fmt"
  5. "testing"
  6. "go-common/library/database/sql"
  7. . "github.com/smartystreets/goconvey/convey"
  8. )
  9. func getPassAid(db *sql.DB) (aid int64, err error) {
  10. if err = db.QueryRow(context.Background(), "select aid from ugc_archive where deleted = 0 and valid = 1 and result = 1 limit 1").Scan(&aid); err != nil {
  11. fmt.Println(err)
  12. }
  13. return
  14. }
  15. func TestDao_RelateAids(t *testing.T) {
  16. Convey("TestDao_RelateAids", t, WithDao(func(d *Dao) {
  17. httpMock("GET", d.relateURL).Reply(200).JSON(`{"data":[{"key": "1234", "value": "23999,515522,55,10099960,10099978,10099959,10099959,10099959,10099959,10099959,10099959,10099959,10099959,10099959,10099959,10099959,10099959,10099959,10099959,10099959,10099959,10099959"}]}`)
  18. aids, err := d.RelateAids(context.Background(), 333444, "")
  19. So(err, ShouldBeNil)
  20. So(len(aids), ShouldBeGreaterThan, 0)
  21. fmt.Println(aids)
  22. }))
  23. }