| 107 | } |
| 108 | |
| 109 | func TestGitModuleSourceSymbolic(t *testing.T) { |
| 110 | testCases := []struct { |
| 111 | name string |
| 112 | cloneRef string |
| 113 | rootSubpath string |
| 114 | expected string |
| 115 | }{ |
| 116 | { |
| 117 | name: "Go-style URL", |
| 118 | cloneRef: "https://github.com/user/repo.git", |
| 119 | rootSubpath: "subdir", |
| 120 | expected: "https://github.com/user/repo.git/subdir", |
| 121 | }, |
| 122 | { |
| 123 | name: "SCP-like reference", |
| 124 | cloneRef: "git@github.com:user/repo.git", |
| 125 | rootSubpath: "subdir", |
| 126 | expected: "git@github.com:user/repo.git/subdir", |
| 127 | }, |
| 128 | { |
| 129 | name: "SCP-like reference with no subdir", |
| 130 | cloneRef: "git@github.com:user/repo.git", |
| 131 | rootSubpath: "", |
| 132 | expected: "git@github.com:user/repo.git", |
| 133 | }, |
| 134 | } |
| 135 | |
| 136 | for _, tc := range testCases { |
| 137 | t.Run(tc.name, func(t *testing.T) { |
| 138 | src := &ModuleSource{ |
| 139 | Kind: ModuleSourceKindGit, |
| 140 | Git: &GitModuleSource{ |
| 141 | CloneRef: tc.cloneRef, |
| 142 | }, |
| 143 | SourceRootSubpath: tc.rootSubpath, |
| 144 | } |
| 145 | result := src.AsString() |
| 146 | require.Equal(t, tc.expected, result, "AsString() returned unexpected result") |
| 147 | }) |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | func moduleSourceTestSyntheticCall(op string, typ dagql.Typed) *dagql.ResultCall { |
| 152 | return &dagql.ResultCall{ |