File tree Expand file tree Collapse file tree 2 files changed +73
-10
lines changed
tests/test-sources/modules Expand file tree Collapse file tree 2 files changed +73
-10
lines changed Original file line number Diff line number Diff line change 9999
100100 config =
101101 let
102+ hasContent = str : ( builtins . match "[[:space:]]*" str ) == null ;
103+
102104 contentLua = ''
103105 ${ config . extraConfigLuaPre }
104- vim.cmd([[
105- ${ config . extraConfigVim }
106- ]])
106+ ${ lib . optionalString ( hasContent config . extraConfigVim ) ''
107+ vim.cmd([[
108+ ${ config . extraConfigVim }
109+ ]])
110+ '' }
107111 ${ config . extraConfigLua }
108112 ${ config . extraConfigLuaPost }
109113 '' ;
110114
111115 contentVim = ''
112- lua << EOF
113- ${ config . extraConfigLuaPre }
114- EOF
116+ ${ lib . optionalString ( hasContent config . extraConfigLuaPre ) ''
117+ lua << EOF
118+ ${ config . extraConfigLuaPre }
119+ EOF
120+ '' }
115121 ${ config . extraConfigVim }
116- lua << EOF
117- ${ config . extraConfigLua }
118- ${ config . extraConfigLuaPost }
119- EOF
122+ ${ lib . optionalString ( hasContent config . extraConfigLua || hasContent config . extraConfigLuaPost ) ''
123+ lua << EOF
124+ ${ config . extraConfigLua }
125+ ${ config . extraConfigLuaPost }
126+ EOF
127+ '' }
120128 '' ;
121129 in
122130 {
Original file line number Diff line number Diff line change 44 # Make sure jsregexp is in LUA_PATH
55 extraConfigLua = ''require("jsregexp")'' ;
66 } ;
7+
8+ # Test that all extraConfigs are present in output
9+ all-configs . module =
10+ { config , ... } :
11+ let
12+ configs = {
13+ extraConfigLuaPre = "string.format('extraConfigLuaPre')" ;
14+ extraConfigLua = "string.format('extraConfigLua')" ;
15+ extraConfigLuaPost = "string.format('extraConfigLuaPost')" ;
16+ extraConfigVim = "let g:var = 'extraConfigVim'" ;
17+ } ;
18+ configAssertion = name : config : {
19+ assertion =
20+ builtins . match ".*extraConfigLuaPre.*" config != null
21+ && builtins . match ".*extraConfigLua.*" config != null
22+ && builtins . match ".*extraConfigLuaPost.*" config != null
23+ && builtins . match ".*extraConfigVim.*" config != null ;
24+ message = "Configuration file ${ name } does not contain all extraConfigs." ;
25+ } ;
26+ in
27+ configs
28+ // {
29+ files = {
30+ "test.lua" = configs ;
31+ "test.vim" = configs ;
32+ } ;
33+
34+ assertions = [
35+ ( configAssertion "init.lua" config . content )
36+ ( configAssertion "test.lua" config . files . "test.lua" . content )
37+ ( configAssertion "test.vim" config . files . "test.vim" . content )
38+ ] ;
39+ } ;
40+
41+ files-default-empty . module =
42+ { config , ... } :
43+ {
44+ files = {
45+ # lua type
46+ "test.lua" = { } ;
47+ # vim type
48+ "test.vim" = { } ;
49+ } ;
50+
51+ assertions = [
52+ {
53+ assertion = builtins . match "[[:space:]]*" config . files . "test.lua" . content != null ;
54+ message = "Default content of test.lua file is expected to be empty." ;
55+ }
56+ {
57+ assertion = builtins . match "[[:space:]]*" config . files . "test.vim" . content != null ;
58+ message = "Default content of test.vim file is expected to be empty." ;
59+ }
60+ ] ;
61+ } ;
762}
You can’t perform that action at this time.
0 commit comments