# # # rename "tests/automate_db_set,get" # to "tests/automate_db_variables" # # patch "tests/automate_db_variables/__driver__.lua" # from [02b5bf1de2e70fcc0861a8f8769a0f844975ccc9] # to [b9e7288aacc0dd94b10534b832b59bbfefbb56b3] # ============================================================ --- tests/automate_db_variables/__driver__.lua 02b5bf1de2e70fcc0861a8f8769a0f844975ccc9 +++ tests/automate_db_variables/__driver__.lua b9e7288aacc0dd94b10534b832b59bbfefbb56b3 @@ -1,13 +1,54 @@ + mtn_setup() -writefile("empty", "") -writefile("expected", "testvalue") +-- +-- check set_db_variable +-- -check(mtn("automate", "db_set", "testdomain", "testname", "testvalue"), 0, true, false) -check(samefile("empty", "stdout")) +check(mtn("automate", "set_db_variable", "domain1", "var", "value"), 0, false, false); +check(mtn("automate", "set_db_variable", "domain2", "var", "value"), 0, false, false); +-- too many arguments +check(mtn("automate", "set_db_variable", "domain1", "var", "new_value", "junk"), 1, false, false); +-- too few arguments +check(mtn("automate", "set_db_variable", "domain1", "other_var"), 1, false, false); -check(mtn("automate", "db_get", "testdomain", "testname"), 0, true, false) -check(samefile("expected", "stdout")) + +-- +-- check get_db_variables +-- + +writefile("expected1", + 'domain "domain1"\n' .. + ' entry "other_var" "value"\n' .. + ' entry "var" "value"\n\n' .. + 'domain "domain2"\n' .. + ' entry "var" "value"\n') + +writefile("expected2", + 'domain "domain2"\n' .. + ' entry "var" "value"\n') + +check(mtn("automate", "set_db_variable", "domain1", "other_var", "value"), 0, false, false); + +check(mtn("automate", "get_db_variables"), 0, true, false) +check(samefile("expected1", "stdout")) + +check(mtn("automate", "get_db_variables", "domain2"), 0, true, false) +check(samefile("expected2", "stdout")) + +check(mtn("automate", "get_db_variables", "unknown_domain"), 1, false, false) + + +-- +-- check drop_db_variables +-- + +check(mtn("automate", "drop_db_variables", "domain1", "var"), 0, false, false); +-- already dropped +check(mtn("automate", "drop_db_variables", "domain1", "var"), 1, false, false); +-- drops vars from domain2 +check(mtn("automate", "drop_db_variables", "domain2"), 0, false, false); +-- otherwise unknown domain +check(mtn("automate", "drop_db_variables", "domain2"), 1, false, false); + --- ensure that missing names fail -check(mtn("automate", "db_get", "testdomain", "testname2"), 1, true, false)