github.com/verrazzano/verrazzano@v1.7.1/platform-operator/internal/monitor/fake/fake_monitor_test.go (about) 1 // Copyright (c) 2022, 2023, Oracle and/or its affiliates. 2 // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. 3 4 package fake 5 6 import ( 7 "fmt" 8 "testing" 9 10 "github.com/stretchr/testify/assert" 11 ) 12 13 func TestFakeMonitorTypeCheckResult(t *testing.T) { 14 a := assert.New(t) 15 16 f := &BackgroundProcessMonitorType{Result: true, Err: nil} 17 res, err := f.CheckResult() 18 a.True(res) 19 a.NoError(err) 20 21 f = &BackgroundProcessMonitorType{Result: false, Err: fmt.Errorf("an unexpected error")} 22 res, err = f.CheckResult() 23 a.False(res) 24 a.Error(err) 25 } 26 27 func TestFakeMonitorTypeIsRunning(t *testing.T) { 28 a := assert.New(t) 29 30 f := &BackgroundProcessMonitorType{Running: true} 31 a.True(f.IsRunning()) 32 33 f = &BackgroundProcessMonitorType{Running: false} 34 a.False(f.IsRunning()) 35 } 36 37 func TestFakeMonitorTypeIsCompleted(t *testing.T) { 38 a := assert.New(t) 39 40 f := &BackgroundProcessMonitorType{Completed: false} 41 a.False(f.IsCompleted()) 42 43 f.SetCompleted() 44 a.True(f.IsCompleted()) 45 }