go.chromium.org/luci@v0.0.0-20240309015107-7cdc2e660f33/lucicfg/testdata/misc/declare_config_set.star (about)

     1  def test_ok():
     2      ctx = __native__.new_gen_ctx()
     3      ctx.declare_config_set("testing/1", ".")
     4      ctx.declare_config_set("testing/1", ".")  # redeclaring is OK
     5      ctx.declare_config_set("testing/1", "subdir/..")  # like this too
     6      ctx.declare_config_set("testing/2", ".")  # intersecting sets are OK
     7      ctx.declare_config_set("testing/3", "subdir")  # nested is fine
     8  
     9  def test_redeclaration():
    10      ctx = __native__.new_gen_ctx()
    11      ctx.declare_config_set("testing", "abc")
    12      assert.fails(
    13          lambda: ctx.declare_config_set("testing", "def"),
    14          'set "testing" has already been declared',
    15      )
    16  
    17  def test_bad_path():
    18      ctx = __native__.new_gen_ctx()
    19      assert.fails(
    20          lambda: ctx.declare_config_set("testing", "/abs"),
    21          "is not allowed",
    22      )
    23      assert.fails(
    24          lambda: ctx.declare_config_set("testing", ".."),
    25          "is not allowed",
    26      )
    27      assert.fails(
    28          lambda: ctx.declare_config_set("testing", "../."),
    29          "is not allowed",
    30      )
    31      assert.fails(
    32          lambda: ctx.declare_config_set("testing", "../dir"),
    33          "is not allowed",
    34      )
    35  
    36  test_ok()
    37  test_redeclaration()
    38  test_bad_path()