blob: db63606359a56d0a357a40753681cd18b64d9035 [file] [log] [blame]
Girish Gowdrae538dfd2019-09-30 11:07:30 +05301/*
2 Copyright (C) 2018 Open Networking Foundation
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17#include "gtest/gtest.h"
18#include "bal_mocker.h"
19#include "core.h"
20
21class TestOltEnable : public ::testing::Test {
22 protected:
23 virtual void SetUp() {
24 }
25
26 virtual void TearDown() {
27 // Code here will be called immediately after each test
28 // (right before the destructor).
29 }
30};
31
32
33// Test Fixture for OltEnable
34
35// Test 1: OltEnableSuccess case
36TEST_F(TestOltEnable, OltEnableSuccess){
37 // NiceMock is used to suppress 'WillByDefault' return errors on using 'NiceMock'.
38 // This is described in https://github.com/arangodb-helper/gtest/blob/master/googlemock/docs/CookBook.md
39 ::testing::NiceMock<BalMocker> balMock;
40 bcmos_errno host_init_res = BCM_ERR_OK;
41 bcmos_errno bal_cfg_get_res = BCM_ERR_NOT_CONNECTED;
42 bcmos_errno olt_oper_res = BCM_ERR_OK;
43
44 Status olt_enable_res;
45
46 // The 'EXPECT_CALL' will do strict validation of input parameters. This may not be relevant for
47 // the current test case. Use 'ON_CALL' instead.
48 // The ON_CALL results in WARNINGs when running tests. Use NickMock instead of directly using BalMocker.
49 // https://github.com/google/googletest/blob/master/googlemock/docs/cook_book.md#the-nice-the-strict-and-the-naggy-nicestrictnaggy
50 // In below tests '::testing::_' does no validation on argument.
51 ON_CALL(balMock, bcmolt_host_init(::testing::_)).WillByDefault(::testing::Return(host_init_res));
52 ON_CALL(balMock, bcmolt_cfg_get(::testing::_,::testing::_)).WillByDefault(::testing::Return(bal_cfg_get_res));
53 ON_CALL(balMock, bcmolt_oper_submit(::testing::_, ::testing::_)).WillByDefault(::testing::Return(olt_oper_res));
54
55 olt_enable_res = Enable_(1, NULL);
56 ASSERT_TRUE( olt_enable_res.error_message() == Status::OK.error_message() );
57}
58