LCOV - code coverage report
Current view: top level - /lua/yoda/testing - defaults.lua (source / functions) Coverage Total Hit
Test: lcov.info Lines: 100.0 % 32 32
Test Date: 2026-04-14 10:33:13 Functions: - 0 0

            Line data    Source code
       1              : -- lua/yoda/testing/defaults.lua
       2              : -- Default test configuration (user-overridable for perfect OCP)
       3              : -- Users can extend without modifying source code via config module
       4              : 
       5            4 : local M = {}
       6              : 
       7              : -- ============================================================================
       8              : -- DEFAULT CONFIGURATIONS (can be overridden by user)
       9              : -- ============================================================================
      10              : 
      11            4 : M.ENVIRONMENTS = {
      12            4 :   qa = { "auto", "use1" },
      13            4 :   fastly = { "auto" },
      14            4 :   prod = { "auto", "use1", "usw2", "euw1", "apse1" },
      15            4 : }
      16              : 
      17            4 : M.ENVIRONMENT_ORDER = { "qa", "fastly", "prod" }
      18              : 
      19            4 : M.MARKERS = {
      20              :   "bdd", -- Default BDD tests
      21              :   "unit", -- Unit tests
      22              :   "functional", -- Functional tests
      23              :   "smoke", -- Smoke tests
      24              :   "critical", -- Critical path tests
      25              :   "performance", -- Performance tests
      26              :   "regression", -- Regression tests
      27              :   "integration", -- Integration tests
      28              :   "location", -- Location-based tests
      29              :   "api", -- API tests
      30              :   "ui", -- UI tests
      31              :   "slow", -- Slow running tests
      32            4 : }
      33              : 
      34            4 : M.MARKER_DEFAULTS = {
      35              :   environment = "qa",
      36              :   region = "auto",
      37              :   markers = "bdd",
      38              :   open_allure = false,
      39            4 : }
      40              : 
      41              : -- ============================================================================
      42              : -- PUBLIC API
      43              : -- ============================================================================
      44              : 
      45              : --- Get test configuration (user-overridable via config module)
      46              : --- @return table Configuration with environments, markers, etc.
      47            4 : function M.get_config()
      48              :   -- Check for user override first (OCP - extend without modification!)
      49            3 :   local user_overrides = vim.g.yoda_test_config
      50              : 
      51            3 :   if user_overrides then
      52              :     return vim.tbl_deep_extend("force", {
      53              :       environments = M.ENVIRONMENTS,
      54              :       environment_order = M.ENVIRONMENT_ORDER,
      55              :       markers = M.MARKERS,
      56              :       marker_defaults = M.MARKER_DEFAULTS,
      57              :     }, user_overrides)
      58              :   end
      59              : 
      60            3 :   return {
      61            3 :     environments = M.ENVIRONMENTS,
      62            3 :     environment_order = M.ENVIRONMENT_ORDER,
      63            3 :     markers = M.MARKERS,
      64            3 :     marker_defaults = M.MARKER_DEFAULTS,
      65            3 :   }
      66            4 : end
      67              : 
      68              : --- Get environments configuration
      69              : --- @return table Environments with regions
      70            4 : function M.get_environments()
      71            3 :   local config = M.get_config()
      72            3 :   return config.environments
      73            4 : end
      74              : 
      75              : --- Get environment order
      76              : --- @return table Ordered list of environment names
      77            4 : function M.get_environment_order()
      78              :   local config = M.get_config()
      79              :   return config.environment_order or M.ENVIRONMENT_ORDER
      80            4 : end
      81              : 
      82              : --- Get markers list
      83              : --- @return table Available test markers
      84            4 : function M.get_markers()
      85              :   local config = M.get_config()
      86              :   return config.markers or M.MARKERS
      87            4 : end
      88              : 
      89              : --- Get marker defaults
      90              : --- @return table Default marker configuration
      91            4 : function M.get_marker_defaults()
      92              :   local config = M.get_config()
      93              :   return config.marker_defaults or M.MARKER_DEFAULTS
      94            4 : end
      95              : 
      96            4 : return M
        

Generated by: LCOV version 2.0-1