2 ==================================================================================
3 Copyright (c) 2020 AT&T Intellectual Property.
4 Copyright (c) 2020 Nokia
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
10 http://www.apache.org/licenses/LICENSE-2.0
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License for the specific language governing permissions and
16 limitations under the License.
17 ==================================================================================
23 "github.com/stretchr/testify/assert"
33 func TestMain(M *testing.M) {
34 o1Agent = NewO1Agent()
36 o1Agent.nbiClient.Start()
39 time.Sleep(time.Duration(1) * time.Second)
43 func TestConsume(t *testing.T) {
44 ret := o1Agent.Consume(nil)
48 func TestConfigChangeHandler(t *testing.T) {
49 o1Agent.ConfigChangeHandler("")
52 func TestStatusCB(t *testing.T) {
53 assert.True(t, o1Agent.StatusCB())
56 func TestSighandler(t *testing.T) {
58 defer func() { osExit = oldOsExit }()
61 osExit = func(code int) {
65 go o1Agent.Sighandler()
66 o1Agent.sigChan <- syscall.SIGTERM
67 time.Sleep(time.Duration(1) * time.Second)
68 assert.Equal(t, 1, exitCode)