You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

122 lines
3.8KB

  1. require 'ostruct'
  2. describe CryptCheck::Status do
  3. describe '::status' do
  4. it 'must handle empty list' do
  5. expect(CryptCheck::Status.status []).to be_nil
  6. end
  7. it 'must answer correctly' do
  8. {
  9. [:critical, :critical] => :critical,
  10. [:critical, :error] => :critical,
  11. [:critical, :warning] => :critical,
  12. [:critical, :good] => :critical,
  13. [:critical, :perfect] => :critical,
  14. [:critical, :best] => :critical,
  15. [:error, :critical] => :critical,
  16. [:error, :error] => :error,
  17. [:error, :warning] => :error,
  18. [:error, :good] => :error,
  19. [:error, :perfect] => :error,
  20. [:error, :best] => :error,
  21. [:warning, :critical] => :critical,
  22. [:warning, :error] => :error,
  23. [:warning, :warning] => :warning,
  24. [:warning, :good] => :warning,
  25. [:warning, :perfect] => :warning,
  26. [:warning, :best] => :warning,
  27. [:good, :critical] => :critical,
  28. [:good, :error] => :error,
  29. [:good, :warning] => :warning,
  30. [:good, :good] => :good,
  31. [:good, :perfect] => :good,
  32. [:good, :best] => :good,
  33. [:perfect, :critical] => :critical,
  34. [:perfect, :error] => :error,
  35. [:perfect, :warning] => :warning,
  36. [:perfect, :good] => :good,
  37. [:perfect, :perfect] => :perfect,
  38. [:perfect, :best] => :perfect,
  39. [:best, :critical] => :critical,
  40. [:best, :error] => :error,
  41. [:best, :warning] => :warning,
  42. [:best, :good] => :good,
  43. [:best, :perfect] => :perfect,
  44. [:best, :best] => :best
  45. }.each do |levels, result|
  46. got = CryptCheck::Status.status levels
  47. expect(got).to be(result), "#{levels} : expected #{result.inspect}, got #{got.inspect}"
  48. end
  49. end
  50. it 'must handle object list' do
  51. critical = OpenStruct.new status: :critical
  52. warning = OpenStruct.new status: :warning
  53. expect(CryptCheck::Status.status [critical, warning]).to be :critical
  54. end
  55. end
  56. describe '::problem' do
  57. it 'must answer correctly' do
  58. {
  59. [:critical, :critical] => :critical,
  60. [:critical, :error] => :critical,
  61. [:critical, :warning] => :critical,
  62. [:critical, :good] => :critical,
  63. [:critical, :perfect] => :critical,
  64. [:critical, :best] => :critical,
  65. [:error, :critical] => :critical,
  66. [:error, :error] => :error,
  67. [:error, :warning] => :error,
  68. [:error, :good] => :error,
  69. [:error, :perfect] => :error,
  70. [:error, :best] => :error,
  71. [:warning, :critical] => :critical,
  72. [:warning, :error] => :error,
  73. [:warning, :warning] => :warning,
  74. [:warning, :good] => :warning,
  75. [:warning, :perfect] => :warning,
  76. [:warning, :best] => :warning,
  77. [:good, :critical] => :critical,
  78. [:good, :error] => :error,
  79. [:good, :warning] => :warning,
  80. [:good, :good] => nil,
  81. [:good, :perfect] => nil,
  82. [:good, :best] => nil,
  83. [:perfect, :critical] => :critical,
  84. [:perfect, :error] => :error,
  85. [:perfect, :warning] => :warning,
  86. [:perfect, :good] => nil,
  87. [:perfect, :perfect] => nil,
  88. [:perfect, :best] => nil,
  89. [:best, :critical] => :critical,
  90. [:best, :error] => :error,
  91. [:best, :warning] => :warning,
  92. [:best, :good] => nil,
  93. [:best, :perfect] => nil,
  94. [:best, :best] => nil
  95. }.each do |levels, result|
  96. got = CryptCheck::Status.problem levels
  97. expect(got).to be(result), "#{levels} : expected #{result.inspect}, got #{got.inspect}"
  98. end
  99. end
  100. it 'must handle object list' do
  101. critical = OpenStruct.new status: :critical
  102. warning = OpenStruct.new status: :warning
  103. expect(CryptCheck::Status.problem [critical, warning]).to be :critical
  104. end
  105. end
  106. end