app_test.go 843 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package service
  2. import (
  3. "context"
  4. "testing"
  5. "go-common/app/admin/main/config/conf"
  6. "github.com/BurntSushi/toml"
  7. . "github.com/smartystreets/goconvey/convey"
  8. )
  9. func svr(t *testing.T) (svr *Service) {
  10. var (
  11. confPath = "../cmd/config-admin-example.toml"
  12. conf *conf.Config
  13. )
  14. Convey("should decodeFile file", t, func() {
  15. _, err := toml.DecodeFile(confPath, &conf)
  16. So(err, ShouldBeNil)
  17. })
  18. return New(conf)
  19. }
  20. func TestService_UpdateToken(t *testing.T) {
  21. svr := svr(t)
  22. Convey("should update token", t, func() {
  23. err := svr.UpdateToken(context.Background(), "dev", "sh001", 2888)
  24. So(err, ShouldBeNil)
  25. })
  26. }
  27. func TestService_AppByName(t *testing.T) {
  28. svr := svr(t)
  29. Convey("should get app by name", t, func() {
  30. app, err := svr.AppByTree(2888, "dev", "sh001")
  31. So(err, ShouldBeNil)
  32. So(app, ShouldNotBeEmpty)
  33. })
  34. }