mockkernel_test.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package mockkernel
  2. import (
  3. "os"
  4. "testing"
  5. "wartank/pkg/components/kernel/slog"
  6. "wartank/pkg/types"
  7. )
  8. const (
  9. path = "./log"
  10. )
  11. // Тестер для мок-объекта ядра
  12. type tester struct {
  13. t *testing.T
  14. err error
  15. kern types.ИЯдро
  16. }
  17. func TestMockKernel(t *testing.T) {
  18. _ = os.RemoveAll(path)
  19. test := &tester{
  20. t: t,
  21. }
  22. test.create()
  23. _ = os.RemoveAll(path)
  24. }
  25. // Создание мок-объекта ядра приложения
  26. func (сам *tester) create() {
  27. сам.t.Logf("create()\n")
  28. сам.kern = NewMockKernel()
  29. if сам.kern == nil {
  30. сам.t.Errorf("create(): app==nil\n")
  31. }
  32. if wg := сам.kern.Wg(); wg == nil {
  33. сам.t.Errorf("create(): wg==nil\n")
  34. }
  35. if ctx := сам.kern.CtxApp(); ctx == nil {
  36. сам.t.Errorf("create(): ctx==nil\n")
  37. }
  38. ядро := сам.kern.(*MockKernel)
  39. ядро.Slog_, сам.err = slog.NewSlog(сам.kern)
  40. if сам.err != nil {
  41. сам.t.Errorf("create(): in create ISlog, err=\n\t%v", сам.err)
  42. }
  43. if slog := сам.kern.Slog(); slog == nil {
  44. сам.t.Errorf("create(): slog==nil")
  45. }
  46. сам.kern.CancelApp()
  47. }