(t *testing.T)
| 18 | ) |
| 19 | |
| 20 | func TestSendCode(t *testing.T) { |
| 21 | viper.Reset() |
| 22 | viper.Set("log.dir", filepath.Join(os.TempDir(), "linkme-test-logs")) |
| 23 | viper.Set("db.dsn", os.Getenv("LINKME_DB_DSN")) |
| 24 | viper.Set("redis.addr", os.Getenv("LINKME_REDIS_ADDR")) |
| 25 | viper.Set("redis.password", os.Getenv("LINKME_REDIS_PASSWORD")) |
| 26 | viper.Set("sms.provider", os.Getenv("LINKME_SMS_PROVIDER")) |
| 27 | viper.Set("sms.tencent.smsID", os.Getenv("LINKME_SMS_TENCENT_SMSID")) |
| 28 | viper.Set("sms.tencent.sign", os.Getenv("LINKME_SMS_TENCENT_SIGN")) |
| 29 | viper.Set("sms.tencent.templateID", os.Getenv("LINKME_SMS_TENCENT_TEMPLATEID")) |
| 30 | logger := ioc.InitLogger() |
| 31 | d := dao.NewSmsDAO(ioc.InitDB(), logger) |
| 32 | c := cache.NewSMSCache(ioc.InitRedis()) |
| 33 | client := ioc.InitSms() |
| 34 | repo := repository.NewSmsRepository(d, c, logger, client) |
| 35 | if er := repo.SendCode(context.Background(), "xxx"); er != nil { |
| 36 | fmt.Println(er) |
| 37 | return |
| 38 | } |
| 39 | } |
nothing calls this directly
no test coverage detected