root/lib/common/tests/health/pcmk__parse_health_strategy_test.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. valid
  2. invalid

   1 /*
   2  * Copyright 2022 the Pacemaker project contributors
   3  *
   4  * The version control history for this file may have further details.
   5  *
   6  * This source code is licensed under the GNU Lesser General Public License
   7  * version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY.
   8  */
   9 
  10 #include <crm_internal.h>
  11 
  12 #include <crm/common/unittest_internal.h>
  13 
  14 static void
  15 valid(void **state) {
     /* [previous][next][first][last][top][bottom][index][help] */
  16     assert_int_equal(pcmk__parse_health_strategy(NULL),
  17                      pcmk__health_strategy_none);
  18 
  19     assert_int_equal(pcmk__parse_health_strategy("none"),
  20                      pcmk__health_strategy_none);
  21 
  22     assert_int_equal(pcmk__parse_health_strategy("NONE"),
  23                      pcmk__health_strategy_none);
  24 
  25     assert_int_equal(pcmk__parse_health_strategy("None"),
  26                      pcmk__health_strategy_none);
  27 
  28     assert_int_equal(pcmk__parse_health_strategy("nOnE"),
  29                      pcmk__health_strategy_none);
  30 
  31     assert_int_equal(pcmk__parse_health_strategy("migrate-on-red"),
  32                      pcmk__health_strategy_no_red);
  33 
  34     assert_int_equal(pcmk__parse_health_strategy("only-green"),
  35                      pcmk__health_strategy_only_green);
  36 
  37     assert_int_equal(pcmk__parse_health_strategy("progressive"),
  38                      pcmk__health_strategy_progressive);
  39 
  40     assert_int_equal(pcmk__parse_health_strategy("custom"),
  41                      pcmk__health_strategy_custom);
  42 }
  43 
  44 static void
  45 invalid(void **state) {
     /* [previous][next][first][last][top][bottom][index][help] */
  46     assert_int_equal(pcmk__parse_health_strategy("foo"),
  47                      pcmk__health_strategy_none);
  48     assert_int_equal(pcmk__parse_health_strategy("custom1"),
  49                      pcmk__health_strategy_none);
  50     assert_int_equal(pcmk__parse_health_strategy("not-only-green-here"),
  51                      pcmk__health_strategy_none);
  52 }
  53 
  54 PCMK__UNIT_TEST(NULL, NULL,
  55                 cmocka_unit_test(valid),
  56                 cmocka_unit_test(invalid))

/* [previous][next][first][last][top][bottom][index][help] */