Advertisement
Guest User

Untitled

a guest
Mar 18th, 2021
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. type ServiceTest struct {
  2. suite.Suite
  3. }
  4.  
  5. func TestInit(t *testing.T) {
  6. suite.Run(t, new(ServiceTest))
  7. }
  8.  
  9. func (t *ServiceTest) SetupSuite() {
  10. t.readConfig()
  11. dictionaries.GDictionaries.LoadDictionaries()
  12. }
  13.  
  14. func (t *ServiceTest) TestQuotes() {
  15. }
  16.  
  17. func (t *ServiceTest) readConfig() {
  18. dir, err := filepath.Abs(filepath.Dir(os.Args[0]))
  19. assert.NoError(t.T(), err)
  20.  
  21. // Checks if executed by go run
  22. if strings.Contains(dir, "go-build") {
  23. dir = "../cmd"
  24. }
  25.  
  26. fi, err := ioutil.ReadDir(dir)
  27. assert.NoError(t.T(), err)
  28.  
  29. for _, fn := range fi {
  30. if fn.Name() == configName {
  31. b, err := ioutil.ReadFile(dir + "/" + configName)
  32. assert.NoError(t.T(), err)
  33.  
  34. err = json.Unmarshal(b, &configReader.GConfig)
  35. assert.NoError(t.T(), err)
  36. }
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement