MCPcopy
hub / github.com/Azure/aztfexport / TestCommondBeforeFunc

Function TestCommondBeforeFunc

command_before_func_test.go:12–240  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

10)
11
12func TestCommondBeforeFunc(t *testing.T) {
13 dirGenEmpty := func(t *testing.T) string {
14 return t.TempDir()
15 }
16 dirGenWithTFBlock := func(content string) func(t *testing.T) string {
17 return func(t *testing.T) string {
18 dir := t.TempDir()
19 if err := os.WriteFile(filepath.Join(dir, "terraform.tf"), []byte(content), 0640); err != nil {
20 t.Fatal(err)
21 }
22 return dir
23 }
24 }
25
26 cases := []struct {
27 name string
28 fset FlagSet
29 dirGen func(t *testing.T) string
30 err string
31 postCheck func(t *testing.T, flagset FlagSet)
32 }{
33 {
34 name: "--append conflicts with --overwrite",
35 fset: FlagSet{
36 flagAppend: true,
37 flagOverwrite: true,
38 },
39 err: "`--append` conflicts with `--overwrite`",
40 },
41 {
42 name: "only a --append works",
43 fset: FlagSet{
44 flagAppend: true,
45 flagSubscriptionId: "123",
46 },
47 },
48 {
49 name: "only a --overwrite works",
50 fset: FlagSet{
51 flagOverwrite: true,
52 },
53 },
54 {
55 name: "--continue shouldn't be used in interactive mode since interactive mode can toggle off the failed resources",
56 fset: FlagSet{
57 flagContinue: true,
58 },
59 err: "`--continue` must be used together with `--non-interactive`",
60 },
61 {
62 name: "--continue with --non-interactive works",
63 fset: FlagSet{
64 flagContinue: true,
65 flagNonInteractive: true,
66 },
67 },
68 {
69 name: "--generate-mapping-file shouldn't be used in interactive mode since interactive mode has a special code to do it",

Callers

nothing calls this directly

Calls 1

commandBeforeFuncFunction · 0.85

Tested by

no test coverage detected