MCPcopy Index your code
hub / github.com/docker-exec/dexec / TestOrdering

Function TestOrdering

cli/cli_test.go:289–348  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

287}
288
289func TestOrdering(t *testing.T) {
290 cases := []struct {
291 osArgs []string
292 want map[OptionType][]string
293 }{
294 {
295 []string{
296 "filename",
297 "-C", "~/foo",
298 "source1.foo",
299 "-b", "b_foo",
300 "-i", "i_foo",
301 "source2.foo",
302 "--arg=a_foobar",
303 "source3.foo",
304 "--build-arg", "b_bar",
305 "--include", "i_bar",
306 "source4.foo",
307 "--arg", "a_bar",
308 "source5.foo",
309 "--build-arg=b_foobar",
310 "--include=i_foobar",
311 "source6.foo",
312 "-a", "a_foo",
313 },
314 map[OptionType][]string{
315 Arg: {
316 "a_foobar", "a_bar", "a_foo",
317 },
318 BuildArg: {
319 "b_foo", "b_bar", "b_foobar",
320 },
321 Include: {
322 "i_foo", "i_bar", "i_foobar",
323 },
324 Source: {
325 "source1.foo",
326 "source2.foo",
327 "source3.foo",
328 "source4.foo",
329 "source5.foo",
330 "source6.foo",
331 },
332 TargetDir: {
333 "~/foo",
334 },
335 },
336 },
337 }
338 for _, c := range cases {
339 got := ParseOsArgs(c.osArgs)
340 if !reflect.DeepEqual(got.Options[BuildArg], c.want[BuildArg]) {
341 t.Errorf("ParseOsArgs %q != %q", got.Options[BuildArg], c.want[BuildArg])
342 } else if !reflect.DeepEqual(got.Options[Arg], c.want[Arg]) {
343 t.Errorf("ParseOsArgs %q != %q", got.Options[Arg], c.want[Arg])
344 } else if !reflect.DeepEqual(got.Options[Source], c.want[Source]) {
345 t.Errorf("ParseOsArgs %q != %q", got.Options[Source], c.want[Source])
346 }

Callers

nothing calls this directly

Calls 1

ParseOsArgsFunction · 0.85

Tested by

no test coverage detected