(t *testing.T)
| 50 | } |
| 51 | |
| 52 | func TestAuthSourceKind(t *testing.T) { |
| 53 | tests := []struct { |
| 54 | name string |
| 55 | auth *Auth |
| 56 | want string |
| 57 | }{ |
| 58 | { |
| 59 | name: "runtime only memory", |
| 60 | auth: &Auth{Attributes: map[string]string{AttributeRuntimeOnly: "true", AttributeSourceBackend: AuthSourcePostgres}}, |
| 61 | want: AuthSourceMemory, |
| 62 | }, |
| 63 | { |
| 64 | name: "backend postgres", |
| 65 | auth: &Auth{Attributes: map[string]string{AttributeSourceBackend: "postgresql", AttributePath: "/tmp/auth.json"}}, |
| 66 | want: AuthSourcePostgres, |
| 67 | }, |
| 68 | { |
| 69 | name: "backend object store", |
| 70 | auth: &Auth{Attributes: map[string]string{AttributeSourceBackend: "object-store", AttributePath: "/tmp/auth.json"}}, |
| 71 | want: AuthSourceObjectStore, |
| 72 | }, |
| 73 | { |
| 74 | name: "config source", |
| 75 | auth: &Auth{Attributes: map[string]string{AttributeSource: "config:codex[abc]"}}, |
| 76 | want: AuthSourceConfig, |
| 77 | }, |
| 78 | { |
| 79 | name: "path source", |
| 80 | auth: &Auth{Attributes: map[string]string{AttributeSource: "/tmp/auth.json"}}, |
| 81 | want: AuthSourceFile, |
| 82 | }, |
| 83 | { |
| 84 | name: "path attribute", |
| 85 | auth: &Auth{Attributes: map[string]string{AttributePath: "/tmp/auth.json"}}, |
| 86 | want: AuthSourceFile, |
| 87 | }, |
| 88 | { |
| 89 | name: "filename fallback", |
| 90 | auth: &Auth{FileName: "codex.json"}, |
| 91 | want: AuthSourceFile, |
| 92 | }, |
| 93 | } |
| 94 | |
| 95 | for _, tt := range tests { |
| 96 | t.Run(tt.name, func(t *testing.T) { |
| 97 | if got := tt.auth.AuthSourceKind(); got != tt.want { |
| 98 | t.Fatalf("AuthSourceKind() = %q, want %q", got, tt.want) |
| 99 | } |
| 100 | }) |
| 101 | } |
| 102 | } |
| 103 | |
| 104 | func TestAccountInfoUsesAuthKind(t *testing.T) { |
| 105 | apiKeyAuth := &Auth{Attributes: map[string]string{AttributeAuthKind: "api-key", AttributeAPIKey: "k"}} |
nothing calls this directly
no test coverage detected