TestAPIKeyPassedAsArg makes sure that only an API key on the command line gives the warning.
(t *testing.T)
| 84 | // TestAPIKeyPassedAsArg makes sure that only an API key on the command line |
| 85 | // gives the warning. |
| 86 | func TestAPIKeyPassedAsArg(t *testing.T) { |
| 87 | cases := []struct { |
| 88 | args []string |
| 89 | want bool |
| 90 | }{ |
| 91 | {[]string{"--serve", "--api-key", "secret"}, true}, |
| 92 | {[]string{"--serve", "--api-key=secret"}, true}, |
| 93 | {[]string{"--serve"}, false}, |
| 94 | {[]string{"--serve", "--address", "127.0.0.1:8080"}, false}, |
| 95 | } |
| 96 | for _, c := range cases { |
| 97 | if got := apiKeyPassedAsArg(c.args); got != c.want { |
| 98 | t.Errorf("apiKeyPassedAsArg(%q) = %v, want %v", c.args, got, c.want) |
| 99 | } |
| 100 | } |
| 101 | } |
nothing calls this directly
no test coverage detected