互动
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
556 B

5 years ago
  1. package test
  2. import (
  3. "github.com/360EntSecGroup-Skylar/excelize/v2"
  4. "hudongzhuanjia/models"
  5. "testing"
  6. "time"
  7. )
  8. func TestAddSensitive(t *testing.T) {
  9. f, err := excelize.OpenFile("敏感词汇.xlsx")
  10. if err != nil {
  11. t.Fatal(err)
  12. }
  13. rows, err := f.GetRows("big_audit_keyword")
  14. for i, row := range rows {
  15. if i == 0 {
  16. continue
  17. }
  18. if err := models.Save(nil, &models.Sensitive{
  19. Keyword: row[1],
  20. Category: row[2],
  21. Host: row[3],
  22. CreateAt: time.Now(),
  23. UpdateAt: time.Now(),
  24. }, nil); err != nil {
  25. t.Fatal(err)
  26. }
  27. }
  28. }