Home
last modified time | relevance | path

Searched hist:bd9bc00b8d7ce2e6631e81a9696addbc399be388 (Results 1 – 5 of 5) sorted by relevance

/openbmc/phosphor-hwmon/test/
H A Denv_mock.hppdiff bd9bc00b8d7ce2e6631e81a9696addbc399be388 Wed Aug 21 12:05:27 CDT 2019 Kun Yi <kunyi731@gmail.com> Rework envMock

Instead of mocking all the functions, only mock std::getenv.
Now each test only needs to provide an EnvImpl that delegate calls to
mockEnv in order to inject dependencies on std::getenv. This for several
reasons:
1. Any call to env::getEnv() will be calling the real implementation of
the C++ code, and testing real code is better than testing mocks.
2. It is easier to write a fake class that takes a config string which
can greatly simplify test cases.
3. We can now write unit tests that ensure the number of times
std::getenv gets called (should be once, but multiple times right now).

Tested: unit tests still pass

Signed-off-by: Kun Yi <kunyi731@gmail.com>
Change-Id: I3e5aff7fa5d025de1b8ae798af43b97d31151ab9
H A Denv_unittest.cppdiff bd9bc00b8d7ce2e6631e81a9696addbc399be388 Wed Aug 21 12:05:27 CDT 2019 Kun Yi <kunyi731@gmail.com> Rework envMock

Instead of mocking all the functions, only mock std::getenv.
Now each test only needs to provide an EnvImpl that delegate calls to
mockEnv in order to inject dependencies on std::getenv. This for several
reasons:
1. Any call to env::getEnv() will be calling the real implementation of
the C++ code, and testing real code is better than testing mocks.
2. It is easier to write a fake class that takes a config string which
can greatly simplify test cases.
3. We can now write unit tests that ensure the number of times
std::getenv gets called (should be once, but multiple times right now).

Tested: unit tests still pass

Signed-off-by: Kun Yi <kunyi731@gmail.com>
Change-Id: I3e5aff7fa5d025de1b8ae798af43b97d31151ab9
H A Dsensor_unittest.cppdiff bd9bc00b8d7ce2e6631e81a9696addbc399be388 Wed Aug 21 12:05:27 CDT 2019 Kun Yi <kunyi731@gmail.com> Rework envMock

Instead of mocking all the functions, only mock std::getenv.
Now each test only needs to provide an EnvImpl that delegate calls to
mockEnv in order to inject dependencies on std::getenv. This for several
reasons:
1. Any call to env::getEnv() will be calling the real implementation of
the C++ code, and testing real code is better than testing mocks.
2. It is easier to write a fake class that takes a config string which
can greatly simplify test cases.
3. We can now write unit tests that ensure the number of times
std::getenv gets called (should be once, but multiple times right now).

Tested: unit tests still pass

Signed-off-by: Kun Yi <kunyi731@gmail.com>
Change-Id: I3e5aff7fa5d025de1b8ae798af43b97d31151ab9
/openbmc/phosphor-hwmon/
H A Denv.hppdiff bd9bc00b8d7ce2e6631e81a9696addbc399be388 Wed Aug 21 12:05:27 CDT 2019 Kun Yi <kunyi731@gmail.com> Rework envMock

Instead of mocking all the functions, only mock std::getenv.
Now each test only needs to provide an EnvImpl that delegate calls to
mockEnv in order to inject dependencies on std::getenv. This for several
reasons:
1. Any call to env::getEnv() will be calling the real implementation of
the C++ code, and testing real code is better than testing mocks.
2. It is easier to write a fake class that takes a config string which
can greatly simplify test cases.
3. We can now write unit tests that ensure the number of times
std::getenv gets called (should be once, but multiple times right now).

Tested: unit tests still pass

Signed-off-by: Kun Yi <kunyi731@gmail.com>
Change-Id: I3e5aff7fa5d025de1b8ae798af43b97d31151ab9
H A Denv.cppdiff bd9bc00b8d7ce2e6631e81a9696addbc399be388 Wed Aug 21 12:05:27 CDT 2019 Kun Yi <kunyi731@gmail.com> Rework envMock

Instead of mocking all the functions, only mock std::getenv.
Now each test only needs to provide an EnvImpl that delegate calls to
mockEnv in order to inject dependencies on std::getenv. This for several
reasons:
1. Any call to env::getEnv() will be calling the real implementation of
the C++ code, and testing real code is better than testing mocks.
2. It is easier to write a fake class that takes a config string which
can greatly simplify test cases.
3. We can now write unit tests that ensure the number of times
std::getenv gets called (should be once, but multiple times right now).

Tested: unit tests still pass

Signed-off-by: Kun Yi <kunyi731@gmail.com>
Change-Id: I3e5aff7fa5d025de1b8ae798af43b97d31151ab9