44 "testing"
55
66 "github.com/stretchr/testify/assert"
7+ "github.com/stretchr/testify/require"
78)
89
910func TestGitNode_ssh (t * testing.T ) {
@@ -13,7 +14,7 @@ func TestGitNode_ssh(t *testing.T) {
1314 assert .NoError (t , err )
1415 assert .Equal (t , "main" , node .ref )
1516 assert .Equal (t , "Taskfile.yml" , node .path )
16- assert .
Equal (
t ,
"ssh://[email protected] /foo/bar.git//Taskfile.yml?ref=main" ,
node .
rawUrl )
17+ assert .
Equal (
t ,
"ssh://[email protected] /foo/bar.git//Taskfile.yml?ref=main" ,
node .
Location () )
1718 assert .
Equal (
t ,
"ssh://[email protected] /foo/bar.git" ,
node .
URL .
String ())
1819 entrypoint , err := node .ResolveEntrypoint ("common.yml" )
1920 assert .NoError (t , err )
@@ -27,7 +28,7 @@ func TestGitNode_sshWithDir(t *testing.T) {
2728 assert .NoError (t , err )
2829 assert .Equal (t , "main" , node .ref )
2930 assert .Equal (t , "directory/Taskfile.yml" , node .path )
30- assert .
Equal (
t ,
"ssh://[email protected] /foo/bar.git//directory/Taskfile.yml?ref=main" ,
node .
rawUrl )
31+ assert .
Equal (
t ,
"ssh://[email protected] /foo/bar.git//directory/Taskfile.yml?ref=main" ,
node .
Location () )
3132 assert .
Equal (
t ,
"ssh://[email protected] /foo/bar.git" ,
node .
URL .
String ())
3233 entrypoint , err := node .ResolveEntrypoint ("common.yml" )
3334 assert .NoError (t , err )
@@ -41,7 +42,7 @@ func TestGitNode_https(t *testing.T) {
4142 assert .NoError (t , err )
4243 assert .Equal (t , "main" , node .ref )
4344 assert .Equal (t , "Taskfile.yml" , node .path )
44- assert .Equal (t , "https://github.com/foo/bar.git//Taskfile.yml?ref=main" , node .rawUrl )
45+ assert .Equal (t , "https://github.com/foo/bar.git//Taskfile.yml?ref=main" , node .Location () )
4546 assert .Equal (t , "https://github.com/foo/bar.git" , node .URL .String ())
4647 entrypoint , err := node .ResolveEntrypoint ("common.yml" )
4748 assert .NoError (t , err )
@@ -55,7 +56,7 @@ func TestGitNode_httpsWithDir(t *testing.T) {
5556 assert .NoError (t , err )
5657 assert .Equal (t , "main" , node .ref )
5758 assert .Equal (t , "directory/Taskfile.yml" , node .path )
58- assert .Equal (t , "https://github.com/foo/bar.git//directory/Taskfile.yml?ref=main" , node .rawUrl )
59+ assert .Equal (t , "https://github.com/foo/bar.git//directory/Taskfile.yml?ref=main" , node .Location () )
5960 assert .Equal (t , "https://github.com/foo/bar.git" , node .URL .String ())
6061 entrypoint , err := node .ResolveEntrypoint ("common.yml" )
6162 assert .NoError (t , err )
@@ -65,18 +66,28 @@ func TestGitNode_httpsWithDir(t *testing.T) {
6566func TestGitNode_CacheKey (t * testing.T ) {
6667 t .Parallel ()
6768
68- node , err := NewGitNode ("https://github.com/foo/bar.git//directory/Taskfile.yml?ref=main" , "" , false )
69- assert .NoError (t , err )
70- key := node .CacheKey ()
71- assert .Equal (t , "Taskfile.yml-directory.f1ddddac425a538870230a3e38fc0cded4ec5da250797b6cab62c82477718fbb" , key )
69+ tests := []struct {
70+ entrypoint string
71+ expectedKey string
72+ }{
73+ {
74+ entrypoint : "https://github.com/foo/bar.git//directory/Taskfile.yml?ref=main" ,
75+ expectedKey : "git.github.com.directory.Taskfile.yml.f1ddddac425a538870230a3e38fc0cded4ec5da250797b6cab62c82477718fbb" ,
76+ },
77+ {
78+ entrypoint : "https://github.com/foo/bar.git//Taskfile.yml?ref=main" ,
79+ expectedKey : "git.github.com.Taskfile.yml.39d28c1ff36f973705ae188b991258bbabaffd6d60bcdde9693d157d00d5e3a4" ,
80+ },
81+ {
82+ entrypoint : "https://github.com/foo/bar.git//multiple/directory/Taskfile.yml?ref=main" ,
83+ expectedKey : "git.github.com.directory.Taskfile.yml.1b6d145e01406dcc6c0aa572e5a5d1333be1ccf2cae96d18296d725d86197d31" ,
84+ },
85+ }
7286
73- node , err = NewGitNode ("https://github.com/foo/bar.git//Taskfile.yml?ref=main" , "" , false )
74- assert .NoError (t , err )
75- key = node .CacheKey ()
76- assert .Equal (t , "Taskfile.yml-..39d28c1ff36f973705ae188b991258bbabaffd6d60bcdde9693d157d00d5e3a4" , key )
77-
78- node , err = NewGitNode ("https://github.com/foo/bar.git//multiple/directory/Taskfile.yml?ref=main" , "" , false )
79- assert .NoError (t , err )
80- key = node .CacheKey ()
81- assert .Equal (t , "Taskfile.yml-directory.1b6d145e01406dcc6c0aa572e5a5d1333be1ccf2cae96d18296d725d86197d31" , key )
87+ for _ , tt := range tests {
88+ node , err := NewGitNode (tt .entrypoint , "" , false )
89+ require .NoError (t , err )
90+ key := node .CacheKey ()
91+ assert .Equal (t , tt .expectedKey , key )
92+ }
8293}
0 commit comments