(t *testing.T)
| 7 | ) |
| 8 | |
| 9 | func TestGetSecretEntity(t *testing.T) { |
| 10 | tests := []struct { |
| 11 | name string |
| 12 | orgName string |
| 13 | envName string |
| 14 | userSecrets bool |
| 15 | want SecretEntity |
| 16 | wantErr bool |
| 17 | }{ |
| 18 | { |
| 19 | name: "org", |
| 20 | orgName: "myOrg", |
| 21 | want: Organization, |
| 22 | }, |
| 23 | { |
| 24 | name: "env", |
| 25 | envName: "myEnv", |
| 26 | want: Environment, |
| 27 | }, |
| 28 | { |
| 29 | name: "user", |
| 30 | userSecrets: true, |
| 31 | want: User, |
| 32 | }, |
| 33 | { |
| 34 | name: "defaults to repo", |
| 35 | want: Repository, |
| 36 | }, |
| 37 | { |
| 38 | name: "Errors if both org and env are set", |
| 39 | orgName: "myOrg", |
| 40 | envName: "myEnv", |
| 41 | wantErr: true, |
| 42 | }, |
| 43 | { |
| 44 | name: "Errors if both org and user secrets are set", |
| 45 | orgName: "myOrg", |
| 46 | userSecrets: true, |
| 47 | wantErr: true, |
| 48 | }, |
| 49 | { |
| 50 | name: "Errors if both env and user secrets are set", |
| 51 | envName: "myEnv", |
| 52 | userSecrets: true, |
| 53 | wantErr: true, |
| 54 | }, |
| 55 | } |
| 56 | |
| 57 | for _, tt := range tests { |
| 58 | t.Run(tt.name, func(t *testing.T) { |
| 59 | entity, err := GetSecretEntity(tt.orgName, tt.envName, tt.userSecrets) |
| 60 | |
| 61 | if tt.wantErr { |
| 62 | assert.Error(t, err) |
| 63 | } else { |
| 64 | assert.NoError(t, err) |
| 65 | assert.Equal(t, tt.want, entity) |
| 66 | } |
nothing calls this directly
no test coverage detected