| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- package mockkernel
- import (
- "os"
- "testing"
- "wartank/pkg/components/kernel/slog"
- "wartank/pkg/types"
- )
- const (
- path = "./log"
- )
- // Тестер для мок-объекта ядра
- type tester struct {
- t *testing.T
- err error
- kern types.ИЯдро
- }
- func TestMockKernel(t *testing.T) {
- _ = os.RemoveAll(path)
- test := &tester{
- t: t,
- }
- test.create()
- _ = os.RemoveAll(path)
- }
- // Создание мок-объекта ядра приложения
- func (сам *tester) create() {
- сам.t.Logf("create()\n")
- сам.kern = NewMockKernel()
- if сам.kern == nil {
- сам.t.Errorf("create(): app==nil\n")
- }
- if wg := сам.kern.Wg(); wg == nil {
- сам.t.Errorf("create(): wg==nil\n")
- }
- if ctx := сам.kern.CtxApp(); ctx == nil {
- сам.t.Errorf("create(): ctx==nil\n")
- }
- ядро := сам.kern.(*MockKernel)
- ядро.Slog_, сам.err = slog.NewSlog(сам.kern)
- if сам.err != nil {
- сам.t.Errorf("create(): in create ISlog, err=\n\t%v", сам.err)
- }
- if slog := сам.kern.Slog(); slog == nil {
- сам.t.Errorf("create(): slog==nil")
- }
- сам.kern.CancelApp()
- }
|