@@ -88,9 +88,47 @@ func TestApplyCommand(t *testing.T) {
8888 },
8989 },
9090 },
91+ {
92+ name : "define_template" ,
93+ root : map [string ]interface {}{
94+ "/home/user/.local/share/chezmoi" : map [string ]interface {}{
95+ "dir/file.tmpl" : `{{ define "foo" }}cont{{end}}{{ template "foo" }}ents` ,
96+ },
97+ },
98+ },
99+ {
100+ name : "partial_template" ,
101+ root : map [string ]interface {}{
102+ "/home/user/.local/share/chezmoi" : map [string ]interface {}{
103+ "dir/file.tmpl" : `{{ template "foo" }}ents` ,
104+ ".chezmoitemplates/foo" : "{{ if true }}cont{{ end }}" ,
105+ },
106+ },
107+ },
108+ {
109+ name : "multiple_templates" ,
110+ root : map [string ]interface {}{
111+ "/home/user/.local/share/chezmoi" : map [string ]interface {}{
112+ "dir/file.tmpl" : `{{ template "foo" }}` ,
113+ "dir/other.tmpl" : `{{ if true }}other stuff{{ end }}` ,
114+ ".chezmoitemplates/foo" : "{{ if true }}contents{{ end }}" ,
115+ },
116+ },
117+ },
118+ {
119+ name : "multiple_associated" ,
120+ root : map [string ]interface {}{
121+ "/home/user/.local/share/chezmoi" : map [string ]interface {}{
122+ "dir/file.tmpl" : `{{ template "foo" }}{{ template "bar" }}` ,
123+ ".chezmoitemplates/foo" : "{{ if true }}cont{{ end }}" ,
124+ ".chezmoitemplates/bar" : "{{ if true }}ents{{ end }}" ,
125+ },
126+ },
127+ },
91128 } {
92129 t .Run (tc .name , func (t * testing.T ) {
93130 tc .root ["/home/user/.local/share/chezmoi/dir/file" ] = "contents"
131+ tc .root ["/home/user/.local/share/chezmoi/dir/other" ] = "other stuff"
94132 tc .root ["/home/user/.local/share/chezmoi/symlink_symlink" ] = "target"
95133 fs , cleanup , err := vfst .NewTestFS (tc .root )
96134 require .NoError (t , err )
@@ -111,6 +149,11 @@ func TestApplyCommand(t *testing.T) {
111149 vfst .TestModePerm (0644 ),
112150 vfst .TestContentsString ("contents" ),
113151 ),
152+ vfst .TestPath ("/home/user/dir/other" ,
153+ vfst .TestModeIsRegular ,
154+ vfst .TestModePerm (0644 ),
155+ vfst .TestContentsString ("other stuff" ),
156+ ),
114157 vfst .TestPath ("/home/user/symlink" ,
115158 vfst .TestModeType (os .ModeSymlink ),
116159 vfst .TestSymlinkTarget ("target" ),
0 commit comments