(t *testing.T, tc *TestContext)
| 40 | } |
| 41 | |
| 42 | func tCreateStorageDefinition(t *testing.T, tc *TestContext) { |
| 43 | var resp struct { |
| 44 | CreateStorageDefinition *struct { |
| 45 | Id string |
| 46 | Identifier string |
| 47 | Config model.S3StorageConfig |
| 48 | IsEnabled bool |
| 49 | Priority int |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | configJSON := `{ |
| 54 | "bucket": "test-bucket", |
| 55 | "endpoint": "us-west-2", |
| 56 | "access": "test", |
| 57 | "secret": "test" |
| 58 | }` |
| 59 | tc.forceAuthenticate(asSiteOwner) |
| 60 | err := tc.client.Post(` |
| 61 | mutation { |
| 62 | createStorageDefinition(input: { |
| 63 | storageType: S3 |
| 64 | configJSON: "`+utils.JsonEscape(configJSON)+`" |
| 65 | identifier: "test" |
| 66 | isEnabled: true |
| 67 | priority: 1 |
| 68 | }) { |
| 69 | id |
| 70 | identifier |
| 71 | isEnabled |
| 72 | priority |
| 73 | config { |
| 74 | ... on S3StorageConfig { |
| 75 | bucket |
| 76 | endpoint |
| 77 | access |
| 78 | secret |
| 79 | } |
| 80 | } |
| 81 | } |
| 82 | }`, &resp) |
| 83 | require.NoError(t, err) |
| 84 | require.NotNil(t, resp.CreateStorageDefinition) |
| 85 | // check that the storage definition was created |
| 86 | storageDefinition, err := tc.storageDefRepo.GetStorageDefinitionByIdentifier("test") |
| 87 | require.NoError(t, err) |
| 88 | require.NotNil(t, storageDefinition) |
| 89 | } |
| 90 | |
| 91 | func tCreateStorageDefinitionWithInvalidConfig(t *testing.T, tc *TestContext) { |
| 92 | var resp struct { |
nothing calls this directly
no test coverage detected