diff options
author | komels <komels@yandex-team.ru> | 2022-04-14 13:10:53 +0300 |
---|---|---|
committer | komels <komels@yandex-team.ru> | 2022-04-14 13:10:53 +0300 |
commit | 21c9b0e6b039e9765eb414c406c2b86e8cea6850 (patch) | |
tree | f40ebc18ff8958dfbd189954ad024043ca983ea5 /library/cpp/tvmauth/client/ut/last_error_ut.cpp | |
parent | 9a4effa852abe489707139c2b260dccc6f4f9aa9 (diff) | |
download | ydb-21c9b0e6b039e9765eb414c406c2b86e8cea6850.tar.gz |
Final part on compatibility layer: LOGBROKER-7215
ref:777c67aadbf705d19034a09a792b2df61ba53697
Diffstat (limited to 'library/cpp/tvmauth/client/ut/last_error_ut.cpp')
-rw-r--r-- | library/cpp/tvmauth/client/ut/last_error_ut.cpp | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/library/cpp/tvmauth/client/ut/last_error_ut.cpp b/library/cpp/tvmauth/client/ut/last_error_ut.cpp new file mode 100644 index 0000000000..6751e78be7 --- /dev/null +++ b/library/cpp/tvmauth/client/ut/last_error_ut.cpp @@ -0,0 +1,56 @@ +#include <library/cpp/tvmauth/client/misc/last_error.h> + +#include <library/cpp/testing/unittest/registar.h> + +using namespace NTvmAuth; + +Y_UNIT_TEST_SUITE(LastError) { + Y_UNIT_TEST(common) { + TLastError le; + + UNIT_ASSERT_VALUES_EQUAL("OK", + le.GetLastError(true)); + UNIT_ASSERT_VALUES_EQUAL("Internal client error: failed to collect last useful error message, please report this message to tvm-dev@yandex-team.ru", + le.GetLastError(false)); + + UNIT_ASSERT_EXCEPTION_CONTAINS(le.ThrowLastError(), + TNonRetriableException, + "Internal client error: failed to collect last useful error message"); + + le.ProcessError(TLastError::EType::Retriable, TLastError::EScope::PublicKeys, "err_re#1"); + UNIT_ASSERT_VALUES_EQUAL("PublicKeys: err_re#1", + le.GetLastError(false)); + le.ProcessError(TLastError::EType::Retriable, TLastError::EScope::PublicKeys, "err_re#2"); + UNIT_ASSERT_VALUES_EQUAL("PublicKeys: err_re#2", + le.GetLastError(false)); + le.ProcessError(TLastError::EType::NonRetriable, TLastError::EScope::PublicKeys, "err_nonre#3"); + UNIT_ASSERT_VALUES_EQUAL("PublicKeys: err_nonre#3", + le.GetLastError(false)); + le.ProcessError(TLastError::EType::NonRetriable, TLastError::EScope::PublicKeys, "err_nonre#4"); + UNIT_ASSERT_VALUES_EQUAL("PublicKeys: err_nonre#4", + le.GetLastError(false)); + le.ProcessError(TLastError::EType::Retriable, TLastError::EScope::PublicKeys, "err_re#5"); + UNIT_ASSERT_VALUES_EQUAL("PublicKeys: err_nonre#4", + le.GetLastError(false)); + UNIT_ASSERT_EXCEPTION_CONTAINS(le.ThrowLastError(), + TNonRetriableException, + "Failed to start TvmClient. Do not retry: PublicKeys: err_nonre#4"); + + le.ProcessError(TLastError::EType::Retriable, TLastError::EScope::ServiceTickets, "err_re#6"); + UNIT_ASSERT_VALUES_EQUAL("PublicKeys: err_nonre#4", + le.GetLastError(false)); + le.ProcessError(TLastError::EType::Retriable, TLastError::EScope::ServiceTickets, "err_re#7"); + UNIT_ASSERT_VALUES_EQUAL("PublicKeys: err_nonre#4", + le.GetLastError(false)); + le.ProcessError(TLastError::EType::NonRetriable, TLastError::EScope::ServiceTickets, "err_nonre#8"); + UNIT_ASSERT_VALUES_EQUAL("ServiceTickets: err_nonre#8", + le.GetLastError(false)); + + le.ClearError(TLastError::EScope::ServiceTickets); + UNIT_ASSERT_VALUES_EQUAL("PublicKeys: err_nonre#4", + le.GetLastError(false)); + le.ClearError(TLastError::EScope::PublicKeys); + UNIT_ASSERT_VALUES_EQUAL("Internal client error: failed to collect last useful error message, please report this message to tvm-dev@yandex-team.ru", + le.GetLastError(false)); + } +} |