MCPcopy
hub / github.com/hashicorp/go-getter / TestHgGetter_HgArgumentsNotAllowed

Function TestHgGetter_HgArgumentsNotAllowed

get_hg_test.go:125–210  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

123 testing_helper.AssertContents(t, dst, "Hello\n")
124}
125func TestHgGetter_HgArgumentsNotAllowed(t *testing.T) {
126 if !testHasHg {
127 t.Log("hg not found, skipping")
128 t.Skip()
129 }
130
131 if runtime.GOOS == "windows" {
132 // Please refer to https://github.com/hashicorp/go-getter/pull/388/files#r1005819432
133 // for more context why we are temporarily skipping Windows OS.
134 t.Log("skipping on Windows OS for now")
135 t.Skip()
136 }
137 ctx := context.Background()
138
139 tc := []struct {
140 name string
141 req Request
142 errChk func(testing.TB, error)
143 }{
144 {
145 // If arguments are allowed in the destination, this request to Get will fail
146 name: "arguments allowed in destination",
147 req: Request{
148 Dst: "--config=alias.clone=!touch ./TEST",
149 u: testModuleURL("basic-hg"),
150 },
151 errChk: func(t testing.TB, err error) {
152 if err != nil {
153 t.Errorf("Expected no err, got: %s", err)
154 }
155 },
156 },
157 {
158 // Test arguments passed into the `rev` parameter
159 // This clone call will fail regardless, but an exit code of 1 indicates
160 // that the `false` command executed
161 // We are expecting an hg parse error
162 name: "arguments passed into rev parameter",
163 req: Request{
164 u: testModuleURL("basic-hg?rev=--config=alias.update=!false"),
165 },
166 errChk: func(t testing.TB, err error) {
167 if err == nil {
168 return
169 }
170
171 if !strings.Contains(err.Error(), "hg: parse error") {
172 t.Errorf("Expected no err, got: %s", err)
173 }
174 },
175 },
176 {
177 // Test arguments passed in the repository URL
178 // This Get call will fail regardless, but it should fail
179 // because the repository can't be found.
180 // Other failures indicate that hg interpreted the argument passed in the URL
181 name: "arguments passed in the repository URL",
182 req: Request{

Callers

nothing calls this directly

Calls 3

testModuleURLFunction · 0.85
GetMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected