(t *testing.T)
| 7 | ) |
| 8 | |
| 9 | func TestFunctionName(t *testing.T) { |
| 10 | type example struct { |
| 11 | name string |
| 12 | args []string |
| 13 | want string |
| 14 | } |
| 15 | for _, test := range []example{ |
| 16 | { |
| 17 | name: "invalid flag without equals", |
| 18 | args: []string{"--cloud", "test", "specific"}, |
| 19 | want: "", |
| 20 | }, |
| 21 | { |
| 22 | name: "valid flag with equals before function", |
| 23 | args: []string{"--cloud=true", "test", "specific"}, |
| 24 | want: "test", |
| 25 | }, |
| 26 | { |
| 27 | name: "no flags before function", |
| 28 | args: []string{"test", "--race", "specific"}, |
| 29 | want: "test", |
| 30 | }, |
| 31 | { |
| 32 | name: "multiple valid flags before function", |
| 33 | args: []string{"--cloud=true", "--value=test", "test", "--race=true", "specific"}, |
| 34 | want: "test", |
| 35 | }, |
| 36 | { |
| 37 | name: "invalid second flag without equals", |
| 38 | args: []string{"--cloud=true", "--race", "test", "specific"}, |
| 39 | want: "", |
| 40 | }, |
| 41 | { |
| 42 | name: "empty args", |
| 43 | args: []string{}, |
| 44 | want: "", |
| 45 | }, |
| 46 | { |
| 47 | name: "only valid flags no function", |
| 48 | args: []string{"--cloud=true", "--race=true"}, |
| 49 | want: "", |
| 50 | }, |
| 51 | { |
| 52 | name: "single dash flags before function", |
| 53 | args: []string{"-m", "dev", "test", "specific"}, |
| 54 | want: "", |
| 55 | }, |
| 56 | } { |
| 57 | t.Run(test.name, func(t *testing.T) { |
| 58 | require.Equal(t, test.want, functionName(test.args)) |
| 59 | }) |
| 60 | } |
| 61 | } |
nothing calls this directly
no test coverage detected