github.com/MetalBlockchain/metalgo@v1.11.9/utils/logging/log_test.go (about)

     1  // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved.
     2  // See the file LICENSE for licensing terms.
     3  
     4  package logging
     5  
     6  import (
     7  	"testing"
     8  
     9  	"github.com/stretchr/testify/require"
    10  )
    11  
    12  func TestLog(t *testing.T) {
    13  	log := NewLogger("", NewWrappedCore(Info, Discard, Plain.ConsoleEncoder()))
    14  
    15  	recovered := new(bool)
    16  	panicFunc := func() {
    17  		panic("DON'T PANIC!")
    18  	}
    19  	exitFunc := func() {
    20  		*recovered = true
    21  	}
    22  	log.RecoverAndExit(panicFunc, exitFunc)
    23  
    24  	require.True(t, *recovered)
    25  }