@@ -4,34 +4,54 @@ package pkg_test
4
4
5
5
import (
6
6
"github.com/wttech/aemc/pkg"
7
+ "github.com/wttech/aemc/pkg/common/pathx"
8
+ "github.com/wttech/aemc/pkg/content"
9
+ "os"
10
+ "path/filepath"
7
11
"testing"
8
12
)
9
13
10
14
func TestDetermineFilterRoot (t * testing.T ) {
15
+ workDir := pathx .RandomDir (os .TempDir (), "filter_root" )
16
+ defer func () { _ = pathx .DeleteIfExists (workDir ) }()
17
+ if err := copyFiles ("int_test_content/repo" , workDir ); err != nil {
18
+ t .Fatal (err )
19
+ }
20
+
11
21
tests := []struct {
12
22
path , expected string
13
23
}{
14
- {"/somepath/jcr_root/content/my_site" , "/content/my_site" },
15
- {"/somepath/jcr_root/content/my_site/_cq_path" , "/content/my_site/cq:path" },
16
- {"/somepath/jcr_root/content/my_site/_xmpBJ_path" , "/content/my_site/xmpBJ:path" },
17
- {"/somepath/jcr_root/content/my_site/_s7sitecatalyst_path" , "/content/my_site/s7sitecatalyst:path" },
18
- {"/somepath/jcr_root/content/my_site/adobe_dam%3apath" , "/content/my_site/adobe_dam:path" },
19
- {"/somepath/jcr_root/content/my_site/_cq__sub_path_" , "/content/my_site/cq:_sub_path_" },
20
- {"/somepath/jcr_root/content/my_site/__cq_path" , "/content/my_site/_cq_path" },
21
- {"/somepath/jcr_root/content/my_site/__abc_path" , "/content/my_site/_abc_path" },
22
- {"/somepath/jcr_root/content/my_site/__path" , "/content/my_site/_path" },
23
- {"/somepath/jcr_root/content/my_site/___path" , "/content/my_site/__path" },
24
- {"\\ somepath\\ jcr_root\\ content\\ my_site" , "/content/my_site" },
25
- {"\\ somepath\\ jcr_root\\ content\\ my_site\\ _cq_path" , "/content/my_site/cq:path" },
26
- {"/somepath/jcr_root/content/my_app/_cq_dialog/.content.xml" , "/content/my_app/cq:dialog" },
27
- {"/somepath/jcr_root/content/my_app/_cq_dialog.xml" , "/content/my_app/cq:dialog" },
28
- {"/somepath/jcr_root/content/my_conf/workflow.xml" , "/content/my_conf/workflow" },
29
- {"/somepath/jcr_root/content/dam/my_site/image.png" , "/content/dam/my_site/image.png" },
30
- {"/somepath/jcr_root/conf/my_site/_sling_configs/com.config.ImageConfig" , "/conf/my_site/sling:configs/com.config.ImageConfig" },
31
- {"/somepath/jcr_root/conf/my_site/_sling_configs/com.config.ImageConfig/_jcr_content" , "/conf/my_site/sling:configs/com.config.ImageConfig/jcr:content" },
24
+ //{"/content/my_site", "/content/my_site"},
25
+ //{"/content/my_site/_cq_path", "/content/my_site/cq:path"},
26
+ //{"/content/my_site/_xmpBJ_path", "/content/my_site/xmpBJ:path"},
27
+ //{"/content/my_site/_s7sitecatalyst_path", "/content/my_site/s7sitecatalyst:path"},
28
+ //{"/content/my_site/adobe_dam%3apath", "/content/my_site/adobe_dam:path"},
29
+ //{"/content/my_site/_cq__sub_path_", "/content/my_site/cq:_sub_path_"},
30
+ //{"/content/my_site/__cq_path", "/content/my_site/_cq_path"},
31
+ //{"/content/my_site/__abc_path", "/content/my_site/_abc_path"},
32
+ //{"/content/my_site/__path", "/content/my_site/_path"},
33
+ {"/content/my_site/___path" , "/content/my_site/__path" },
34
+ {"content\\ my_site" , "/content/my_site" },
35
+ {"content\\ my_site\\ _cq_path" , "/content/my_site/cq:path" },
36
+ {"/content/my_app/_cq_dialog/.content.xml" , "/content/my_app/cq:dialog" },
37
+ {"/content/my_app/_cq_dialog.xml" , "/content/my_app/cq:dialog" },
38
+ {"/content/my_conf/workflow.xml" , "/content/my_conf/workflow" },
39
+ {"/content/dam/my_site/image.png" , "/content/dam/my_site/image.png" },
40
+ {"/conf/my_site/_sling_configs/com.config.ImageConfig" , "/conf/my_site/sling:configs/com.config.ImageConfig" },
41
+ {"/conf/my_site/_sling_configs/com.config.ImageConfig/_jcr_content" , "/conf/my_site/sling:configs/com.config.ImageConfig/jcr:content" },
42
+ {"/apps/mysite/components/helloworld/_cq_template/.content.xml" , "/apps/mysite/components/helloworld/cq:template" },
43
+ {"/apps/mysite/components/helloworld/_cq_template.xml" , "/apps/mysite/components/helloworld/cq:template" },
44
+ {"/apps/mysite/components/helloworld/_cq_editConfig.xml" , "/apps/mysite/components/helloworld/cq:editConfig" },
45
+ {"/apps/mysite/components/helloworld/helloworld.html" , "/apps/mysite/components/helloworld/helloworld.html" },
46
+ {"/conf/mysite/_sling_configs/com.mysite.pdfviewer.PdfViewerCaConfig" , "/conf/mysite/sling:configs/com.mysite.pdfviewer.PdfViewerCaConfig" },
47
+ {"/conf/mysite/_sling_configs/com.mysite.pdfviewer.PdfViewerCaConfig/.content.xml" , "/conf/mysite/sling:configs/com.mysite.pdfviewer.PdfViewerCaConfig/jcr:content" },
48
+ {"/conf/mysite/_sling_configs/.content.xml" , "/conf/mysite/sling:configs" },
49
+ {"/conf/mysite/_sling_configs" , "/conf/mysite/sling:configs" },
50
+ {"/content/mysite/us/en/.content.xml" , "/content/mysite/us/en/jcr:content" },
32
51
}
33
52
for _ , test := range tests {
34
- actual := pkg .DetermineFilterRoot (test .path )
53
+ path := filepath .Join (workDir , content .JCRRoot , test .path )
54
+ actual := pkg .DetermineFilterRoot (path )
35
55
if actual != test .expected {
36
56
t .Errorf ("DetermineFilterRoot(%s) = %s; want %s" , test .path , actual , test .expected )
37
57
}
0 commit comments